Abstract modification method summary

Source: Internet
Author: User

Abstract: This method is mainly used in abstract classes and abstract methods.

Abstract classes cannot be instantiated, such

Public abstract class test {

}

He can contain abstract methods

Public abstract class test {

Public abstract void defmethod ();

}

The abstract method is to let the subclass inherit and then define it, so that the abstract concept can be designed. For example, when an object-oriented design encounters a method with multiple designs, the design work can be handed over to the subclass when the base class is not designed for the time being, you can either continue to inherit the abstract concepts of its superclasses or define the abstract methods.

For example

Abstract class Test2 extends test {

........

}

The abstract method of the super class is still not defined, and the abstract concept is handed over to the subclass of test2.

Class Test2 extends test {

Public void demethod (){

}

}

Inherit from test to design abstract concepts. Although no statement exists in {}, it also means that we have made a design for it, a definition of nothing. Suppose that the definition can be written in.

Summary:

A method without a method body in a class is an abstract method.

Classes that contain abstract methods are abstract classes.

If a subclass does not implement all abstract methods in the abstract base class, the subclass can also become an abstract class.

We can declare a class without any abstract method as abstract, so that no matter what object is generated by this class.

Abstract modification method summary

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.