JAVA base (1) - Object Oriented Features

1. abstract
things in real life is abstracted into an object, the object has the same attributes and behavior is abstracted into a class, and then abstract parent class from a class with the same properties and behavior of. (To identify common portion extraction)

2. Package
property and implementation details hidden object, only open to the public interface. 

3. inheritance
inheritance relationship between the child and parent classes, subclasses can obtain the properties and methods of the parent class.
Note: For sub-class private methods of the parent class can inherit? 
From the language point of view: JDK official documents explicitly subclass can not inherit private methods of the parent class; 
but from the perspective of memory, jvm, will create a parent object in memory before instance subclasses of objects, then placed outside the parent object property unique to the subclass, the two together form a subclass object. So subclass does have all the attributes and methods of the parent class, but private subclass the parent class is not accessible.

4. Polymorphic
java language to allow a reference type variable reference instance of a subclass, and may convert the reference variable type.
1. triplet variety of interface inheritance class overrides 2. Method Based on

Guess you like

Origin blog.51cto.com/4397014/2436216