Abstract class:
In Java, a method that has no method body is defined, and the method is implemented specifically by its subclasses.
The method that does not have a method body is called an abstract method, and the class containing the abstract method is an abstract class.
Features of abstract methods:
1. Methods that only the method head has no method body
2. Abstract modification of methods
3. Abstract methods represent an indeterminate operation or behavior
4. Abstract methods cannot be called
Features of abstract classes:
1. Classes that contain abstract methods in definitions are called abstract classes
2. Abstract modification of classes
3. Abstract class represents an abstract object type
4. Abstract classes cannot be instantiated
5. Abstract classes can have specific methods, can have no abstract method
All employees of the company have job number, name, salary and work. Leadership in addition to the employee's attributes and methods there are allowances for public class Employeedemo {public static void main (string[] args) {//TODO auto-generated method Stubjav Ateacher teacher = new Javateacher (001, "Zhang San", +); Teacher.work (); leader lead = new leader (002, "John Doe", 5000,10000); Lead.work ();}} Abstracted class employee{//abstract class private int number;private String name;private double salary;public abstract void work ();//Pumping Like method public employee (int number,string name,double salary) {this.number = Number;this.name = Name;this.salary = salary;} Abstract classes can have not only abstract methods, but also concrete methods public void AA () {System.out.println ("AAA" +number+name+salary);}} A class inherits an abstract class, either implementing a method of an abstract class, or continuing to abstract the class Javateacher extends Employee{public javateacher (int number,string name,double Salary) {super (number,name,salary);} Implementation of the abstract method public void work () {System.out.println ("on Java Lesson");}} Class Leader extends Employee{private double allowance;//grant public leader (int number,string name,double salary,double Allowance) {super (number,name,salary); this.allowance = allowance;} Implementation of the abstract method PuBlic void Work () {System.out.println ("Training new employee, allowance:" +allowance);}}
Java abstract classes and abstract methods