ProgrammingModerateProduct-company placement · Java

A base type must hold common fields, have a constructor that validates them, and share some method bodies, while subclasses form a strict is-a hierarchy. Which Java construct fits best?

  1. A. An interface with default methods
  2. B. A final class
  3. C. An enum
  4. D. An abstract class

Correct answer: D. An abstract class

Interfaces cannot have instance fields or constructors; default methods can share behaviour but not state. An abstract class provides state, constructors and partial implementation while forbidding direct instantiation.

More OOP with C++ and Java questions

Exams that ask this topic