[Java] [VIDEO] Notes-abstract class

Source: Internet
Author: User

1 When you use the abstract keyword to decorate a class, a class is called an abstract class;

When you use abstract to modify a method, the method is called an abstract method.

2 classes that contain abstract methods must be declared as abstract classes

Abstract classes must be inherited, and abstract methods must be overridden.

Abstract classes cannot be instantiated.

3 When a method is declared with the abstract keyword, then the class is incomplete, and the class must also be declared abstract, and the class cannot be instantiated.

If the abstract method is not overridden in a subclass, the subclass will also error. The best solution is to override the method in a subclass, and if you really think that this method should not be overridden, you can also declare the method as abstract in the subclass, which is also the abstract class.

Abstract classes and Methods summary:

In an abstract class, there can be no abstract method. But if there is an abstract method in a class, the class must be an abstract class.

[Java] [VIDEO] Notes-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.