Java Class (i): abstract class

Source: Internet
Author: User
Tags function definition

Tag:abs    is    nbsp   class    features      Special    bsp   nal   abstract   

/*
When the same functionality appears in more than one class, but the functional body is different,
this is possible to pull up. At this point, only the function definition is extracted, not the functional body.

Abstract: Can't read. Features of the

Abstract class:
1, .
2, both abstract methods and abstract classes must be decorated with the abstract keyword.
3, abstract class cannot use new to create an object . Because it doesn't make sense to invoke an abstract method.
4, abstract methods in the abstract class to be used, you must copy all the abstract methods from the child class, to establish a subclass object call.
     .
5. Abstract methods in abstract classes do not have a body, and he needs subclasses to do this and interface very similar;


Abstract classes are not much different from generic classes.
How to describe things, how to describe things, but there are some things that are not understood. The
these indeterminate parts, which are also the function of the thing, need to be clearly present. However, the principal cannot be defined. The
is represented by an abstract method. The

Abstract analogy generally has multiple abstract functions. is to define an abstract method in a class. The
abstract class cannot be instantiated.


Special: An abstract method can be undefined in an abstract class, only to not allow the class to establish an object.


Exercise:

The abstract keyword, and which keywords cannot coexist.
Final: The final decorated class cannot have subclasses. The class that is modified by the abstract must be a parent class.
Private: A private abstract method in an abstract class that cannot be replicated without being known to the class.
         The abstract method appears to be the need to be replicated.
Static: If static can modify the abstract method, then even the object is saved, and the direct class name is called.
         But abstract methods do not make sense.

Java Class (i): 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.