The concept of abstract classes:
A class that contains an abstract method is an abstract class
Abstract method:
A method that is declared without being implemented is an abstract method that must be declared with the abstract keyword
It is important to note that
1. When an abstract class quilt inherits, subclasses (if not abstract classes) must override the "all" abstract method in the abstract class
2. Abstract classes cannot be instantiated directly, they need to be instantiated by their subclasses
The definition format of an abstract class:
Abstract class classname{
Property
Method
Abstract methods
}
The code is as follows:
Package Hello;abstract class Abs{private int age;public int. getage () {return age;} public void Setage (int.) {this.age = age;} public void Tell () {}abstract public void Say ();} Class Demo extends Abs{public void Say () {}}public class Abstractdemo {public static void main (string[] args) {Demo Ademo = New Demo (); System.out.println (Ademo.getage ());}}
Java abstract class and abstract keyword