The difference between Java abstract class and ordinary class

Source: Internet
Author: User

1. Abstract classes cannot be instantiated.

2. Abstract classes can have constructors, which are inherited when the subclass must inherit a constructor of the parent class, and the abstract method cannot be declared static.

3. Abstract methods only need to declare, without implementation, the abstract class can allow the normal method has the principal

4. Classes that contain abstract methods must be declared as abstract classes

5. An abstract subclass must implement all abstract methods in an abstract class, or the subclass is an abstract class.

Can abstract classes have constructors? The answer is yes. The constructor of an abstract class is used to initialize some fields of an abstract class, all of which occur before the derived class of the abstract class is instantiated. Not only that, the constructor of the draw line class has a clever application: The code that implements the subclass must execute inside it

The difference between Java abstract class and ordinary 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.