Java keyword-abstract

Source: Internet
Author: User
Tags define abstract

Abstract: Not specific, can not understand.

Abstract class representation manifests itself. In the continuous extraction process, the common content of the method declaration extraction, but the method is not the same, no extraction, then the method extracted, not specific, need to be specified by the keyword abstract marked, declared as an abstract method.

The class in which the abstract method resides must be marked as an abstract class, meaning that the class needs to be decorated with the abstract keyword.

Features of abstract classes:

1: Abstract methods can only be defined in abstract classes, abstract classes and abstract methods must be decorated by the abstract keyword (you can describe classes and methods, and you cannot describe variables).

2: Abstract methods define method declarations only and do not define method implementations.

3: Abstract class can not be created object (instantiation).

4: This subclass can be instantiated only if the subclass inherits the abstract class and overrides all abstract methods in the abstract class. Otherwise, the subclass is an abstract class.

The details of the abstract class:

1: Is there a constructor in an abstract class? There, used to initialize the subclass object.

2: Is it possible to define non-abstract methods in an abstract class? OK. In fact, there is not much difference between abstract class and general class, it is to describe things, but abstract classes describe things, some functions are not specific. Therefore, both abstract and generic classes need to define properties and behaviors in the definition. However, there is an abstract function more than the general class. And it's a little less than a generic class. The part that creates the object.

3: Abstract keyword and which cannot coexist? Final, private, static

4: Can I not define abstract methods in an abstract class? OK. The abstract method is intended only to keep the class from creating objects.

Java keyword-abstract

Related Article

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: 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.