Sorry I am a newbie to Java. I am trying to get my head around inheritance and subclass/superclass relationships in Java.
If classA is a subclass of classB, will classA's protocol feature all methods that belong to classA or only those declared public and package?
Can classA's protocol feature private methods inherited from its superclass ClassB?
Firstly, the word "inherited" isn't quite the right term. You mean "visible".
public
and protected
are always visibleprivate
is not visibleAll public and protected methods and variables will be inherited. Any methods with the same signature in the subclass will override the superclass behavior. The subclass will not inherit private methods and variables. Default (a.k.a package visibility level) will be inherited if in the same pacakge and by subclasses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With