1.

Which of these keywords can be used to prevent Method overriding?(a) static(b) constant(c) protected(d) finalThis question was addressed to me in unit test.I'm obligated to ask this question of Method overriding in chapter Inheritance of Java

Answer»

The correct OPTION is (d) final

Easy explanation: To disallow a method from being OVERRIDDEN, specify final as a modifier at the start of its declaration. METHODS DECLARED as final cannot be overridden.



Discussion

No Comment Found

Related InterviewSolutions