What problem does an interface primarily solve in OOP?
Practice this question from Quiz: OOPS Revision Sheet, with options and an explanation.
Question
What problem does an interface primarily solve in OOP?
Option A
It provides a default implementation for common behaviors.
Option B — Correct answer
It defines a contract that implementing classes must adhere to.
Interfaces define contracts, specifying what methods must be implemented by any class that implements the interface.
Option C
It allows classes to inherit state from multiple parent classes.
Option D
It hides all implementation details of a class.