Question 52Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Method over-riding can be prevented by using final as a modifier at
Athe start of the class.
Bthe start of method declaration.
Cthe start of derived class.
Dthe start of the method declaration in the derived class.
Show answerHide answer
Correct answer: (B) the start of method declaration.
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.
From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)