Difficulty: Easy
Correct Answer: Object is an instance of a class.
Explanation:
Introduction:
Object-oriented programming distinguishes between type definitions and the concrete entities created at runtime. This question checks the fundamental terminology connecting classes and objects.
Given Data / Assumptions:
Concept / Approach:
A class is a user-defined type—a blueprint. An object is a particular instance of that type that occupies memory and participates in computation. Many objects can be created from one class, each with its own state, while sharing behavior defined by the class.
Step-by-Step Solution:
1) Define a class: struct Point { int x; int y; };2) Create objects: Point p1; Point p2;3) Observe that p1 and p2 are instances of Point with separate storage.4) Conclude: an object is an instance of its class.
Verification / Alternative check:
sizeof(Point) gives the size of the type; allocating Point p; reserves memory for an instance, showing the distinction between definition (class) and instance (object).
Why Other Options Are Wrong:
Class as an instance of object or data type: reverses the relationship; classes are types.Object as an instance of data type (generic): incomplete; in OOP we specifically say “instance of a class.”
Common Pitfalls:
Confusing class (type) with object (value). Remember: classes are compile-time constructs; objects exist at runtime.
Final Answer:
Object is an instance of a class.
Discussion & Comments