Java abstract class

Source: Internet
Author: User

Classes declared with the abstract keyword become "abstract classes". An abstract method is an incomplete method in which only one declaration has no body part of the method.

1  Public Abstract classAbstracttest {2     3     //Abstract Methods4      Public Abstract voidtest1 ();5     6     //Non-abstract methods7      Public voidtest2 () {8SYSTEM.OUT.PRINTLN ("Non-abstract method in abstract class");9     }Ten  One}

The above code explains that abstract classes are incomplete classes, and the methods are not fully implemented.

And look at the code below.

1  Public classAbstractextendsextendsAbstracttest {2 3 @Override4      Public voidtest1 () {5         //TODO auto-generated Method Stub6 7     }8 9      Public Static voidMain (string[] args) {TenAbstracttest abstracttest =Newabstracttest () { One  A @Override -              Public voidtest1 () { -                 //TODO auto-generated Method Stub the  -             } -         }; -     } +}

Attention:

1. Abstract classes cannot be instantiated directly,

2. When inheriting an abstract class, you need to override each abstract method in the class.

Java abstract class

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.