Application Development using
JAVA
(COURSE CODE: B18CS3105)
Differences between Interface & Abstract
class
Sri. [Link] RAO
Assistant Professor
Department of Computer Science and Engineering
SRKR Engineering College, Bhimavaram, A.P. - 534204
OBJECTIVES
The Objective of this lecture is
• To learn about the differences between
Interface and Abstract class in JAVA.
Differences between an Interface & Abstract class
Interface Abstract class
If we don’t know anything about If we are talking about
implementation and just we have implementation but not completely
requirement specification then we then we should go for abstract
go for interface. class.
Interface can have only abstract Abstract class can have both
methods. abstract and concrete methods.
It supports multiple inheritance It does not support multiple
inheritance.
we can not declare any other There are no restrictions on
modifier rather than public and abstract class method modifiers.
abstract for interface methods.
Every variable present inside Every variable present inside
interface is always public static final abstract class need not be public
whether we are declaring or not. static final.
Differences between an Interface & Abstract class
Interface Abstract class
We can not declare interface There are no restrictions on
variables other than public static abstract class variable modifiers.
final.
For interface variables compulsory For abstract class variables we are
we should perform initialization at not required to perform
the time of declaration only. initialization at the time of
Otherwise we will get compile time declaration.
error.
Interface can not have static Abstract class can have static
methods, main method and methods, main method and
constructor. constructor.
THANK YOU