- A Yes, private methods can be overridden in Java.
- B No, private methods cannot be overridden in Java.
- C Private methods can be overridden but only within the same class.
- D Private methods cannot be overridden but can be accessed using reflection.
- Share this MCQ
Answer:
C
Share this MCQ
Private methods in Java can be overridden but only within the same class. This is because private methods are not visible outside the class and hence cannot be accessed from any other class. Private methods can be overridden by creating a new method with the same name and parameters in the same class. The new method will override the existing private method. However, private methods cannot be overridden in a subclass.
Click me to Read more Question & Answer of Java Interviews MCQsShare this MCQ