Java Review notes abstract classes and interfaces

Source: Internet
Author: User

This series is the Java lessons from July to August for the internship interview ~

abstract classes and Interfaces

is Java

2 mechanisms for defining abstract concepts.

Abstract class

A class does not have enough information to describe a specific object and requires other specific classes to support it.

Abstract class embodies the data abstraction of four small, is a mechanism to implement polymorphism.

It defines a set of abstract methods that are implemented by a derived class for the specific representation of this set of abstract methods. At the same time, abstract classes provide the concept of inheritance, the starting point is to inherit , otherwise it does not exist any meaning. Therefore, the definition of the abstract class must be used to inherit, at the same time in an abstract class as a node of the inheritance relationship hierarchy chain, the leaf node must be a specific implementation class.

1, abstract class can not be instantiated, the work of the instantiation should be left to its subclasses to complete, it only need to have a reference.

2. Abstract methods must be overridden by subclasses.

3. As long as an abstract class containing an abstract method, the method must be defined as an abstract class, whether or not there are other methods included.

4, the abstract class can contain specific methods, of course, can not contain abstract methods.

5. Abstract methods in subclasses cannot have the same name as the abstract methods of the parent class.

6. Abstract cannot be modified in the same class as final. (Abstract & Static is a bug in the Java language a final class can ' t be extended, an abstract class needs to be extended In order to be instantiated. Therefore, a final abstract class would be a logical contradiction.)

Java Review notes abstract classes and interfaces

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.