When would you choose an interface over an abstract class in Java?
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
Use an interface to define a capability that unrelated classes can implement, such as a payment gateway contract. Use an abstract class when implementations genuinely share state, construction rules, or protected implementation that belongs to a common hierarchy. A class can implement multiple interfaces but extends only one class. Default interface methods can share behavior, but they do not tu an interface into a place for per-instance mutable fields. Favor the smallest useful contract and test implementations against shared behavioral expectations rather than exposing unnecessary inheritance details.
Related Questions in Java
Advanced Java Interview Questions and Answers
Advanced level • 845 views
Java Web development interview questions
Advanced level • 666 views
Java Interview questions
Advanced level • 633 views
Java questions for Newbies
Intermediate level • 579 views
Interview questions on EJB
Advanced level • 458 views