Java based learning, (6) - Access to inherit +

A succession of related concepts:

Inheritance can be described as B A: B is one of A, B is the inheritance relationship of A, B inherits from A.

All members of the subclass automatically has a base class (parent class) (including the member variable and methods).

java only supports single inheritance, c ++ supports multiple inheritance, but there are a variety of Java semantics exist.

 

 child classes n_private = 10 is wrong, because the subclass has access to private variables of the parent class, but not the right to use; namely private variables can only be accessed in the parent class object! ! !

 Second, access control:

Permissions object members are private, default, protected, public.

Permissions class is only public, default.

 

 

 

 

 

 

Blog reference Mashi Bing Java foundation tutorial PPT, if infringement, please contact delete, thank you!

Guess you like

Origin www.cnblogs.com/Harriett-Lin/p/12636632.html