Java--Abstract class

Source: Internet
Author: User

1. The concept and function of abstract class:

In Java, you can define a method without a method body, which is implemented by its subclasses, and the method without the method body is called an abstract method. Classes that contain abstract methods are called abstract classes.

2, the characteristics of abstract methods:

A. Only method headers, methods that have no method body are called abstract methods.

B. Abstract methods are used to modify abstractions.

C. Abstract methods represent an indeterminate method of grass operation or behavior.

D. Abstract methods cannot be called. * * can only be overridden by a quilt class.

3, the characteristics of abstract class:

A. A class that contains abstract methods in a definition is called an abstract class.

B. Abstract classes are modified with abstract,

C. An abstract class represents an abstract object type.

D. Abstract classes cannot be instantiated.

E. There can be specific methods in an abstract class, and there can be no abstract method. That is, the class containing the abstract method must be an abstract class, but abstract classes do not necessarily contain abstract methods.

4, a class to inherit the abstract class, or continue to abstract down, or write his specific implementation method.

5. Template method Model: definition: A template method defines an algorithm with some abstract operations, and subclasses redefine the specific behavior that these operations provide.

Intent: Define an algorithmic framework in an operation, defer some steps to subclasses, and template method pattern allows subclasses to redefine new algorithm steps without altering the algorithm structure.

Example: Analyze the design based on the given content:

All employees in the company have a job number, salary, and name.

The teaching director not only has all the attributes of the employee, but also the teaching allowance.

Mathematical modeling of the given analysis

    

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