Which methods can a subclass inherit in Java?

后端 未结 6 1461
说谎
说谎 2021-02-09 19:12

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\

6条回答
  •  面向向阳花
    2021-02-09 19:44

    Firstly, the word "inherited" isn't quite the right term. You mean "visible".

    • public and protected are always visible
    • private is not visible
    • default (a.k.a. "package") visibility - ie no specified visibility - is visible only if the subclass is in the same package (as it be would for any class in the same package)

提交回复
热议问题