Q8
In Java, can a subclass override a private method from its superclass?
A.
No, private methods cannot be overridden
B.
Yes, regardless of the access modifier
C.
Yes, as long as it's in the same package
D.
No, private methods are not visible to subclasses
AnswerAnswer: Option D
Solution
Answer: Option D
Solution:
In Java, private methods of a superclass are not accessible outside that class, including its subclasses.Since a subclass cannot see a private method of its superclass, it cannot override it.
Even if a subclass declares a method with the same name and signature, it is treated as a new method, not an overridden one.
Option A states a general rule but Option D gives the precise reason for why overriding is not possible.
Therefore, the correct answer is Option D – No, private methods are not visible to subclasses.