OCA Java SE 8 Class Design - OCA Mock Question Class Design 13








Question

Which of the following may only be hidden and not overridden? (Choose all that apply)

  1. private instance methods
  2. protected instance methods
  3. public instance methods
  4. static methods
  5. public variables
  6. private variables




Answer



A, D, E, F.

Note

B and C are incorrect because protected and public methods may be overridden, not hidden.

A is correct because private methods are always hidden in a subclass.

D is correct because static methods cannot be overridden, only hidden.

E and F are correct because variables may only be hidden, regardless of the access modifier.