A superclass declares public void f(). Which access level may a subclass use when overriding f()?
Correct answer A. public only
Explanation
An overriding method must offer at least the access of the method it overrides, because a subclass object must be usable wherever the superclass is expected. Since public is the widest level, only public is allowed here. Attempting protected or weaker access is a compile-time error. A protected method, by contrast, may be widened to public.
Answer checked How we write and check questions
Discussion