Inherited class, abstract class

inherit

Subclass will automatically have all inheritable properties and methods of the parent class (private, not inherited)

 

In the program, if you want to declare a class inherits from another class, use the extends keyword.

format:

subclass extends parent class {}

case

 

 

 

 

 

 

         When inherited, the child-parent class has the same name as variables: If a subclass that they have to use their own, not to use the parent class.

 

1.1 Methods Notes overridden method must meal and type the name of the same parameters can be rewritten as well.

 

 

 

 

 

 

 

this and super

 

 

 

Self-understanding animal which contains everything inside subclass, the subclass just call the parent class.

Abstract class

 

 

// inherited abstract class that must be rewritten in him all the abstract methods

Abstract classes are not necessarily methods which abstract methods.

Present inside the class abstract methods must be abstract.

You can not coexist abstract keyword abstract and which keywords?    

l 1, private: private subclass inherits is unable to, there was no coverage, using a modified method abstract and private together, both abstract subclass to implement this method, while the private simply can not be modified subclass the parent class this way. contradictory.

Because the abstract class can not inherit

 

Guess you like

Origin www.cnblogs.com/pandam/p/10960171.html