Difference Wiki

Abstract Class vs. Interface

The main difference between abstract class and interface is that the procedures of Java interface are essentially abstract and cannot have applications. So broadly stating, interface is actually a contract and when we talk about interface, it applies that the methods do not have a body, it is just a pattern. While abstract classes are basically the classes which are expensive to use. Abstract classes and interface is a whole different concept, these are two different things but at times their implementations are quite similar.

Key Differences

An abstract class is object orientated while interface is function oriented.
Abstract class gives a common base class application but nothing of such happens in interface.
Aimie Carlson
May 25, 2015
When you want API to stay constant for a while then you choose interface over abstract class.
Multiple inheritances could be gained by implying multiple interfaces. While in abstract class, you cannot get multiple inheritances.
In interface, all the methods you implement are public but in abstract class you can also apply some non-public methods.
Aimie Carlson
May 25, 2015
If you have a vibe that you in future you would need to add methods in your work then abstract class is opted, not interface.
Aimie Carlson
May 25, 2015
ADVERTISEMENT
Constructors are not there in interface but they do occur in abstract class.
Aimie Carlson
May 25, 2015
Complete member of abstract class could be static but not of interface.

Abstract Class and Interface Definitions

Interface

A surface forming a common boundary between adjacent regions, bodies, substances, or phases.

Interface

A point at which independent systems or diverse groups interact
"the interface between crime and politics where much of our reality is to be found" (Jack Kroll).

Interface

A system of interaction or communication between a computer and another entity such as a printer, another computer, a network, or a human user.

Interface

A device, such as a cable, network card, monitor, or keyboard, that enables interaction or communication between a computer and another entity.
ADVERTISEMENT

Interface

The layout or design of the interactive elements of a computer program, an online service, or an electronic device.

Interface

To join by means of an interface.

Interface

To serve as an interface for.

Interface

To serve as an interface or become interfaced.

Interface

Usage Problem To interact or coordinate smoothly
"Theatergoers were lured out of their seats and interfaced with the scenery" (New York Times).

Interface

The point of interconnection or contact between entities.
Public relations firms often serve as the interface between a company and the press.
ADVERTISEMENT

Interface

A thin layer or boundary between different substances or two phases of a single substance.
If water and oil are mixed together, they tend to separate, and at equilibrium they are in different strata with an oil-water interface in between.
The surface of a lake is a water-air interface.

Interface

(computing) The point of interconnection between systems or subsystems.
The data is sent over the air interface to the remote system.

Interface

(computing) The connection between a user and a machine.
The options are selected via the user interface.

Interface

The connection between parts of software; also the public or published sections of an object or module,
This interface is implemented by several Java classes.
Traits are somewhat between an interface and a mixin, as an interface contains only method signatures, while a trait includes also the full method definitions; on the other side mixins include method definitions, but they can also carry state through attributes, while traits usually don't.

Interface

In object-oriented programming, a piece of code defining a set of operations that other code must implement.
The Audio and Video classes both implement the IPlayable interface.

Interface

(biochemistry) The internal surface of a coiled protein (compare exoface).

Interface

(transitive) To construct an interface for.

Interface

(ambitransitive) To connect through an interface.

Interface

(intransitive) To serve as an interface.

Interface

To meet for discussion.
Let's interface on Wednesday.

Interface

A surface forming a common boundary between two things, especially between two fluids.

Interface

Hardware that links one device with another (especially a computer).

Interface

That part of a computer program which controls the way a program interacts with a user; the manner of inputting and outputting of data, and the way information is presented on a computer monitor; also called user interface; as, a graphical user interface; a character-based interface.

Interface

(chemistry) a surface forming a common boundary between two things (two objects or liquids or chemical phases)

Interface

(computer science) a program that controls a display for the user (usually on a computer monitor) and that allows the user to interact with the system

Interface

The overlap where two theories or phenomena affect each other or have links with each other;
The interface between chemistry and biology

Interface

(computer science) computer circuit consisting of the hardware and associated circuitry that links one device with another (especially a computer and a hard disk drive or other peripherals)

What is Abstract Class?

An abstract class is not completely implied by the programmer. An abstract class may have one or more abstract methods. They are useful for modelling a class grouping or ranking and while while this is being carried out, the programmer get the idea of what has to be build after seeing the requirements. Abstract class cannot be relied upon completely because it lacks some parts. The main point behind this argument is, the abstract class is strictly object oriented, although it has a method heading but no body. When we talk about abstract classes, there is a strong connection between two classes, because theses classes tend to gain or inherit from one another.

What is Interface?

When we talk about interface, on the contrary then the relation or communication between interface itself and the class implying the interface is not as strong as it is in abstract classes. A Java class can implement many interfaces but can inherit from a single abstract class. So, that means that when you want to imply many interactions at one time then interface is your thing. Apart from this whole scenario, even when you do not want the API to change for a while then interface is the best option for you. Interface is actually the contract between two different objects. To cut it short, interface revolves around the functionality.

Trending Comparisons

New Comparisons