ProgrammingHardProduct-company placement · GATE CS

How many of these statements about Java methods are correct? 1. A final method can be overloaded in a subclass. 2. A static method can be overridden by a static method in a subclass. 3. A private method can be overridden in a subclass. 4. An overriding method may declare a subtype as its return type. 5. An overriding method may reduce the visibility, e.g. public to protected.

  1. A. 1
  2. B. 3
  3. C. 4
  4. D. 2

Correct answer: D. 2

1 is true (final stops overriding, not overloading) and 4 is true (covariant returns). A same-signature static method HIDES rather than overrides, private methods are not inherited, and narrowing visibility is a compile error.

More OOP with C++ and Java questions

Exams that ask this topic