Answers

Question and Answer:

  Home  Java Classes

⟩ What is difference between abstract class and interface?

1. Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. Interface is a Java Object containing method declaration and doesn't contain implementation. The classes which have implementing the Interfaces must provide the method definition for all the methods.

2. Abstract class is a Class prefix with a abstract keyword followed by Class definition. Interface is a Interface which starts with interface keyword.

3. Abstract class contains one or more abstract methods. where as Interface contains all abstract methods and final declarations.

4. Abstract class contains the method definition of the some methods. but Interface contains only method declaration, no definition provided.

5. Abstract classes are useful in a situation that Some general methods should be implemented and specialization behavior should be implemented by child classes. Interfaces are useful in a situation that all properties should be implemented we can use this scenario

 163 views

More Questions for you: