Difference between Abstract class and Interface

Difference between Abstract class and Interface

by Administrator | 05-Apr-2020

Tags:  Abstract Class  Interface  Difference


Abstract Class


An abstract class can have both abstract and non-abstract/concrete methods

An Interface can only have abstract methods

An abstract class can have members with various access levels like private, protected, default etc

An interface must have all the members as public

Abstract class has constructer

Interfaces don’t have a constructer

Abstract class can have instance variable

Interface can’t have an instance variable

Abstract class can have variables with different types of modifier

Interface can have variable only with public static final modifier

An abstract class can have static methods

Interface cannot have static methods

You extend an abstract class

You implement an interface

A class can extend only one abstract class

A class can implement multiple interfaces

A Java abstract class should be extended using keyword extends

Java interface should be implemented using keyword implements

An abstract class can extend another Java class and implement multiple interfaces

An interface can extend only interfaces

An abstract class cannot be instantiated, but can be invoked if a main() exists

Interfaces are 100% abstract and cannot be instantiated


There are no comments.

Enter a new Comment:

Copyright Šprgrmmng. All rights reserved.