Abstract class for Java

Source: Internet
Author: User

Rules for abstract classes:

1. Abstract classes can have no abstract methods, classes with abstract methods must be abstract classes

2. Non-abstract classes inherit abstract classes, and all abstract methods of the abstract class must be implemented

3. Abstract classes, like ordinary classes, can have method implementations and properties

4. Abstract classes cannot be instantiated

5. Abstract classes cannot be declared final.

The existence of an abstract class is for the quilt class to inherit, and the final decorated class indicates that the class cannot be inherited, so using final to modify the abstract class is a few meanings?

Abstract class example{    publicabstractvoid foo ();   declare only, do not implement }classextends  example{    public Abstract void foo () {        System.out.println ("test for Abstract of class!" );    }}

Abstract class for Java

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.