Within a subclass you can access its superclass's public and protected methods and fields
, but not the superclass's private methods.
If the subclass and the superclass are in the same package, you can also access the superclass's default methods and fields.
public class P {
public void publicMethod() {
}
protected void protectedMethod() {
}
void defaultMethod() {
}
}
class C extends P {
public void testMethod() {
publicMethod();
protectedMethod();
defaultMethod();
}
}