The direct differences and connections between abstract classes, interfaces, and parent classes in Java

Source: Internet
Author: User

1, the difference between abstract class and interface:

(1) An abstract class is a class that has only variables or method declarations, and these variables (attributes) and methods are abstract types. There is no implementation of the method for the abstract class.

(2) An interface is a method declaration only. Without the implementation of a method, the method of an interface is also an abstract method, unlike an abstract class: an interface can only define static final member variables.

2, abstract class and interface in common:

The method implementations of an abstract class and an interface are implemented in an inherited (subclass) or class that implements an interface.


2. The difference between an abstract class and a parent class:

(1) The abstract class differs from the parent class in that the abstract class can only declare a property or method and cannot implement it. The subclass that inherits this class must implement all methods of the abstract class.

(2) The parent class is also the declaration and implementation of properties and methods, and cannot be defined without implementation.


This article is from the "Trials and hardships" blog, please be sure to keep this source http://carben.blog.51cto.com/8690350/1626612

The direct differences and connections between abstract classes, interfaces, and parent classes in Java

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.