A class cannot be declared:

  1. Static

  2. Private

  3. Default


Correct Option: B

AI Explanation

To answer this question, we need to understand the different access modifiers in Java and how they can be applied to class declarations.

A. Static: A class can be declared as static in Java. When a class is declared as static, it means that it can be accessed without creating an instance of that class.

B. Private: A class cannot be declared as private in Java. The private access modifier is used to restrict access to members (variables and methods) within the same class. However, it cannot be applied to class declarations.

C. Default: A class can be declared with the default access modifier in Java. If no access modifier is specified for a class, it is considered to have default access. This means that the class can be accessed within the same package but not from outside the package.

Therefore, the correct answer is B) Private. This option is incorrect because a class cannot be declared as private in Java.

Find more quizzes: