Abstract classes and Interfaces in Java

Source: Internet
Author: User

The main content is from MIT6.031 software construction course and hit software construction course.

Before we introduce the abstract class, let's talk about abstract methods.

Abstract methods are those methods that only method declarations (methods Signature), and no method body, or method implementations, are decorated with the abstract keyword.

The concrete implementation of the abstract method is usually done by inheriting the subclass of the class in which the abstract method resides.

The following is an abstract class:

Abstract classes are: Classes that contain at least one abstract method are abstract classes.

Interface (Interface):
Interfaces are an efficient way to design ADT (Abstract Data Type) in Java, by creating classes to implement an interface.

An interface can extend other interfaces, or it can implement other interfaces.

Starting with JAVA8, interfaces are also allowed to include static methods that can be used to perform creator operations such as constructors (constructor) and so on.

The relationships of abstract classes and interfaces are:

An interface is an abstract class that has only abstract methods, and an interface is a special kind of abstract class.

Abstract classes and Interfaces 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.