Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core%20Java%20Interview%20Questions%20and%20Answers

Question: What are the differences between an interface and an abstract class?
Answer:
  • An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.
  • Abstract class are used only when there is a "IS-A" type of relationship between the classes. Interfaces can be implemented by classes that are not related to one another and there is "HAS-A" relationship. 
  • You cannot extend more than one abstract class. You can implement more than one interface. 
  • Abstract class can implement some methods also. Interfaces can not implement methods. 
  • With abstract classes, you are grabbing away each class’s individuality. With Interfaces, you are merely extending each class’s functionality.
  • As per Java 8, interface can have method body as well.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook