The abstraction of Java learning

Source: Internet
Author: User
Tags define abstract

When the same functionality appears in more than one class, but the functional body is different, it is possible to pull up, at which point only the function definition is extracted and the functional body is not extracted.

Abstract: Can not understand.

Features of abstract classes:

1. Abstract methods must be defined in abstract classes

2. Abstract methods and abstract classes must be decorated with the abstract keyword

3. Abstract classes cannot create objects with new because it makes no sense to invoke abstract methods

4. The method in the abstract class is to be used, after all its abstract methods have been replicated by the subclass, a subclass object call is made, and if the subclass covers only a subset of the abstract methods, then the subclass is an abstract class

Abstract classes and general classes are not much different, how to describe things, just how to describe things, but there are some things that things do not understand, these uncertain parts, but also the function of the thing, need to explicitly appear, but can not define the subject, through the abstract method to express.

Abstract analogy is a general class of abstract functions, that is, you can define abstract methods in a class, abstract classes cannot be instantiated

Note: Abstract methods may not be defined in an abstract class, and this simply does not allow the class to establish an object.

The abstraction of Java learning

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.