A, abstract and concrete difference between
Abstract methods: modifier abstract return value type method name (parameter list);
An abstract method has no method body {}
Specific methods: modifier return value type method name (parameter list) {method}
1. The modification with the abstract keyword
2. Format: the abstract class class name {}
Public abstract void eat ();
Second, the characteristics of the abstract class
1. Do not necessarily have abstract method in an abstract class (can have abstract method also can have specific method), a class of abstract methods must be abstract class
2. An abstract class cannot be instantiated, through polymorphic forms realize instantiation
Animal a=new Dog ();
3. In an abstract class can have abstract method, also can not
4. Member features:
A. member variables:
Can be variable, also can be custom constants (final)
Private final int num=10;
B. constructor:
Not useless, for a subclass object creation is access to the parent class constructor
C. member methods:
Can be either abstract method, also can be specific methods
5. A subclass of the abstract class:
A. must be abstract class
B. must be rewritten all the abstract methods in the abstract class
Interface (and class level)
Interface features:
A, interface characteristic
1. Key words: interface
2. Format: interface interface name {}
Public interface Jump {}
Two, class implements the interface with implements said
Format: name of class class implements the interface name {}
Public class JumpCat Jump {}
Three, interface cannot be instantiated
So, how interface instantiation?
According to the polymorphic way, from the concrete subclasses of instantiation,
Or is the abstract class
要么重写口中的所有抽象方法


















CodePudding user response:
This characteristic is the Delphi?