Answer the question
In order to leave comments, you need to log in
Why should the overridden method of the child class be no less accessible than in the parent class from the point of view of the JVM?
The book says that you cannot specify the status of a method that you are overriding as private if the parent has public. From the compiler's point of view, this is normal, but the jvm will already stumble upon a problem. What can happen if you do this, from the jvm point of view?
Answer the question
In order to leave comments, you need to log in
Because LSP (Barbara Liskov Substitution Principle). Where you use a base class, you should be able to use descendants. If you make access more strict, this principle is violated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question