"Nine" abstract classes and abstract functions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.