OOPS Question

Difference between Abstract class and Interface.

#Capgemini#SeniorSoftwareEngineer
4 views
Answers (1)

Submit your answer

CodingNinjas
CodingNinjas
Answered Mar 09, 2022

Answer : 
The differences between Abstract Class and Interface are as follows:

Abstract Class:

1) Abstract classes have a default constructor and it is called whenever the concrete subclass is instantiated.
2) It contains Abstract methods as well as Non-Abstract methods.
3) The class which extends the Abstract class shouldn’t require the implementation of all the methods, only Abstract methods need to be implemented in the concrete sub-class.
4) Abstract class contains instance variables.

Interface:

1 )It doesn’t have any constructor and couldn’t be instantiated.
2) The abstract method alone should be declared.
3) Classes that implement the interface should provide the implementation for all the methods.
4) The interface contains only constants.

Report

Report Interview Advice

What’s wrong with this interview advice?