Content: abstract, interface, polymorphism
#########################################################################################################
1. Abstract
If the method is abstract, then the class must also be abstract
Abstract class cannot pass new object
Only when the subclass covers all abstract methods can the subclass create objects through new. If it does not cover all abstract methods, then the subclass is still an abstract class
Abstract keyword abstract and final, private, static cannot coexist
eg11 class ChouXiang 2 { 3 public static void main(String[] args) 4 { 5 Programmer p = new Programmer("jiang","ji357",7600); 6 Manager m =new Manager("x","g009",12000,60000); 7 p.work(); 8 m.work(); 9 p.show(); 10 m.show(); 11 } 12 } 13 14 abstract class Employee 15 { 16 private String name; 17 private String id; 18 private double salary; 19 20 Employee(String name,String id,double salary) 21 { 22 this.name = name; 23 this.id = id; 24 this.salary = salary; 25 } 26 abstract void work(); 27 void show() 28 { 29 System.out.println("name:"+name+", id:"+id+", salary:"+salary); 30 } 31 } 32 33 class Programmer extends Employee 34 { 35 Programmer(String name,String id,double salary) 36 { 37 super(name,id,salary); 38 } 39 void work() 40 { 41 System.out.println("code"); 42 } 43 } 44 45 class Manager extends Employee 46 { 47 private double bonus; 48 Manager(String name,String id,double salary,double bonus) 49 { 50 super(name,id,salary); 51 this.bonus = bonus; 52 } 53 void work() 54 { 55 System.out.println("manage"); 56 } 57 }