1. methods In a class are called abstract methods if only declarations are not implemented. abstract methods must be used for modification. abstract classes with abstract methods are called abstract classes. abstract methods must also be used for modification, abstract classes can have no abstract methods. abstract classes cannot be created:
View plaincopy to clipboardprint?
// Abstract class
Abstract class {
// Abstract Method
Abstract public void proc ();
}
// Abstract classes without abstract methods
Abstract class B {
Public void proc (){
}
}
Public class Main {
Public static void main (String [] args ){
// The abstract class cannot be created. The following two statements are incorrect.
A a = new ();
B B = new B ();
}
}
// Abstract class
Abstract class {
// Abstract Method
Abstract public void proc ();
}
// Abstract classes without abstract methods
Abstract class B {
Public void proc (){
}
}
Public class Main {
Public static void main (String [] args ){
// The abstract class cannot be created. The following two statements are incorrect.
A a = new ();
B B = new B ();
}
}
2. A subclass inherited from an abstract class. If it does not cover all methods of the abstract base class, it is also an abstract class and must be modified using abstract:
View plaincopy to clipboardprint?
// Abstract class
Abstract class {
// Abstract Method
Abstract public void proc ();
}
Abstract class B extends {
}
// Abstract class
Abstract class {
// Abstract Method
Abstract public void proc ();
}
Abstract class B extends {
}
3. All methods in the interface are abstract methods. They can only have public or default modifiers, and cannot have private or protected modifiers.
4. The interface can contain fields. These fields are implicitly declared as static final, that is, the fields in the interface can be considered as constants.