ProgrammingEasyAccenture · Cognizant pattern

In Java, final applied to a class, a method and a variable means, respectively:

  1. A. Cannot be instantiated; cannot be overridden; cannot be reassigned
  2. B. Cannot be instantiated; cannot be overloaded; cannot be read
  3. C. Cannot be subclassed; cannot be overloaded; must be static
  4. D. Cannot be subclassed; cannot be overridden; cannot be reassigned

Correct answer: D. Cannot be subclassed; cannot be overridden; cannot be reassigned

A final class (like String) has no subclasses, a final method cannot be overridden (it can still be overloaded), and a final variable is assigned exactly once. Preventing instantiation is what abstract or a private constructor does.

More OOP with C++ and Java questions

Exams that ask this topic