Foundation concepts: which statement about objects and classes is correct?

Difficulty: Easy

Correct Answer: An object is an instance of a class.

Explanation:


Introduction / Context:
Objects and classes are the bedrock of object-oriented analysis and design. A class defines a type (its structure and behavior), and objects are concrete instances of that type that exist at runtime with specific state.



Given Data / Assumptions:

  • Classes define attributes and operations.
  • Objects realize those definitions with concrete values and identity.
  • Encapsulation applies to both, but neither limits “only data.”


Concept / Approach:
Distinguish type vs. instance. The type (class) is a blueprint; the instance (object) is a realized entity in memory or persistence with its own attribute values. Therefore, the precise, universally correct statement is that an object is an instance of a class.



Step-by-Step Solution:

Reject statements reversing the type–instance relationship.Reject statements that claim “only data”; objects and classes include data and behavior.Select the accurate pairing: object → instance of class.


Verification / Alternative check:
In code, declaring “new Customer()” creates an object (instance) of class Customer; many such objects can exist simultaneously.



Why Other Options Are Wrong:
Class is an instance of an object is backwards.
Only data ignores methods/behavior, which are intrinsic in OO.



Common Pitfalls:
Assuming a class is merely a “record structure”; in OO it encapsulates both data and operations.



Final Answer:
An object is an instance of a class.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion