Java specifies that methods may not be overridden to be more private. For example, if you have a base class A and a derived class B declared like this:
the compiler will give you an error at line 6: "Cannot reduce the visibility of the inherited method from A"
posted 13 years ago
Thanks for the reply. I have one more doubt. If a method cannot be overriden to be more private. Then is the other way round works. That mean a protected method in super class can be defined in subclass as public method?
And the reason for this is Liskov's Substitution Principle: a subclass should be usable anywhere the superclass can be used. So if a client can access a method in the superclass, he should be able to access the same method in all subclasses, too.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Create Edit Print & Convert PDF Using Free API with Java