Examveda

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

Answer: Option D

Solution (By Examveda Team)

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.

This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Comments (1)

  1. Narayan Panigrahi
    Narayan Panigrahi:
    4 months ago

    A option is also correct beacause private method cannot be override in subclass A and B option are correct only they are written in different way

Related Questions on Overriding and Overloading