Which statement about abstract classes and interfaces is true?

Prepare for the Object-Oriented Programming Test with flashcards and multiple choice questions. Each question comes with hints and explanations to enhance understanding. Master OOP concepts and succeed in your exam!

Multiple Choice

Which statement about abstract classes and interfaces is true?

Explanation:
The key idea is the difference between state and contract. An abstract class acts as a partially implemented blueprint: it can hold data in fields (state) and can provide concrete methods with common behavior, along with abstract methods that subclasses must implement. An interface, on the other hand, describes a contract: it specifies what methods a class must offer, without tying those methods to any per‑instance data. In practice, interfaces don’t store instance state (they may declare constants, but not fields that belong to an object). So the statement is true because it captures that abstract classes can carry state and provide default behavior, while interfaces define behavior a class must implement without storing state. Some languages add nuances like default methods in interfaces, but the core distinction remains about state versus contract.

The key idea is the difference between state and contract. An abstract class acts as a partially implemented blueprint: it can hold data in fields (state) and can provide concrete methods with common behavior, along with abstract methods that subclasses must implement. An interface, on the other hand, describes a contract: it specifies what methods a class must offer, without tying those methods to any per‑instance data. In practice, interfaces don’t store instance state (they may declare constants, but not fields that belong to an object). So the statement is true because it captures that abstract classes can carry state and provide default behavior, while interfaces define behavior a class must implement without storing state. Some languages add nuances like default methods in interfaces, but the core distinction remains about state versus contract.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy