0% found this document useful (0 votes)
19 views4 pages

Key Differences Between Abstract Classes and Interfaces

An interface is not a class and all its methods are public by default, with methods only declared and never defined. Variables in an interface are final and static, and any concrete class implementing the interface must define all its methods. Interfaces can extend other interfaces but cannot implement them, and they can only be referenced by object variables, not instantiated directly.

Uploaded by

roshanscorp275
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Key Differences Between Abstract Classes and Interfaces

An interface is not a class and all its methods are public by default, with methods only declared and never defined. Variables in an interface are final and static, and any concrete class implementing the interface must define all its methods. Interfaces can extend other interfaces but cannot implement them, and they can only be referenced by object variables, not instantiated directly.

Uploaded by

roshanscorp275
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Abstract class and interface are almost similar except some key differences – Interface is not class, it

and all its declared methods are public by default (need not mention public explicitly), methods are
only declared in interface and never defined. All variables defined in interface are final and static by
default.
It is imperative that a concrete class implementing the interface defines all its methods else the class
implementing the interface will become abstract class by default.

Since interface variables are static they can be directly referred by interface.
Interfaces can only be provided as reference for an object variable, they cannot be object of
interface type. Objects are created only for class type.

Interface to interface extension. Interface cannot implement but extend another interface.

You might also like