Discussion Forum

Can we override private methods in Java?

Can we override private methods in Java?

by Sanjay Kumar Sharma -
Number of replies: 2

Can we override private methods in Java?

In reply to Sanjay Kumar Sharma

Re: Can we override private methods in Java?

by Ashutosh Bhatt -
In Java, methods declared as private can never be overridden. Because it's bonded during compile time using static binding.
In reply to Sanjay Kumar Sharma

Re: Can we override private methods in Java?

by Waseem Bakr -
Since overriding requires inheritance and method visibility, a private method is not inherited by the child class. If a subclass defines a method with the same name as a private method in the parent class, it is treated as a completely new method, not an overridden one. This is why access modifiers play an important role in method overriding. If you need help understanding such Java concepts, you can check reviews for Take my class online us for academic support.