The difference and connection between Java interface and abstract class and concrete class

Source: Internet
Author: User

The OOP language, in order to increase the reusability and maintainability of ADT, usually requires the use of interfaces and abstract classes. Let's look at the differences between interfaces, abstract classes, and specific classes:

Object-oriented programming, one of the main ideas is abstraction. Interfaces and abstract classes are abstract.

In the interface, there are no specific attributes, only the corresponding methods and corresponding parameters and return values are specified. This is the highest degree of abstraction, and it is necessary to find all the commonalities of the object to be represented, and to judge all the actions that will satisfy its application. Then, in the implementation of the interface, for different object instances, the method in the interface is implemented differently.

and for abstract class, is lower than the interface of the abstraction, it found some of the similarities between the objects, and then in their own internal implementation of a certain function, but also a number of abstract methods, so that the specific class inheriting it can be based on different characteristics of the abstract method of different abstractions.

and the concrete class is the class that we actually apply in the application. For these classes, there can be no abstract method inside, and all methods should have a concrete implementation. At the same time an abstract class can be implemented on multiple interfaces, only the abstract method in the override interface is required. A concrete class can inherit only one abstract class, and then override the abstract method in the abstract class. This is a difference between an abstract class and a concrete class. At the same time, in the interface, there is no attribute, all methods are abstract methods, and in the abstract class, you can have specific properties, some methods can be implemented, but still require a part of the method is abstract, otherwise it is not called abstract class, which is another difference between abstract classes and interfaces.

The difference and connection between Java interface and abstract class and concrete class

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