Abstract classes and abstract methods

Source: Internet
Author: User

What is an abstract method? Abstract methods are modified by the keywords abstract, and there is no method body for abstract methods, that is, no curly brackets. For example, abstract function demo ();

What is an abstract class? An abstract class is a class modified with abstract keywords. An abstract class must have at least one abstract method. An abstract class cannot create an object,Therefore, the abstract class cannot access non-static attributes.. Others can be accessed. Abstract classes and interfaces are used to develop specifications so that third-party programs can be added.Subclass inherits abstract classes to implement all abstract methods of abstract classesOtherwise, this subclass is also an abstract class. After the subclass implements the abstract method of the abstract class (override the abstract method of the abstract class, add curly brackets), The subclass can create an object, and the subclass object can access the attributes and methods in the 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.