1 classChinese extends absperson{2 3 Chinese () {4 super ();5System. out. println ("the Chinese constructor");6 }7 //above is the constructor of the abstract class8 voideat () {9System. out. println ("eat with chopsticks");Ten } One //override the abstract function inside the abstract class, so that Chinese can use the A}
1 Abstract classabsperson{2 Absperson () {3System. out. println ("the Absperson constructor");4 }5 //abstract class constructor, abstract class is also a constructor, in the generation of objects will be called6 String name;7 intAge ;8 9 voidintroduce () {TenSystem. out. println ("My name is"+ name +", my age is"+Age ); One } A - Abstract voideat (); -}
1 class testabs{2 Public Static void Main (String args []) {3 New Chinese (); 4 ap.eat (); 5 }6 }
This test also uses an upward transformation, as well as a method that calls the sub-class that points
It's going to be a power cut, first.
"Nine" abstract classes and abstract functions