ITPEC FE Subject A April 2024 Question 35

Which of the following represents the appropriate combination of a class and an object in Object Oriented Programming?

OptionClassObject

Explanation

A class groups objects with the same attributes and behavior; an object is an instance of a class — the class is the definition, the object is the concrete thing.

A class defines the attributes and methods shared by a kind of object. Creating (instantiating) an object from that class gives an instance with its own attribute values, while its behavior comes from the class definition.

Answer (a)

Why not others:

  • •(b) — the class half is right, but an object is not the blueprint of its class; the class is the blueprint of its objects
  • •(c) — reverses both roles: a class is not an instance, and it is the class, not the object, that serves as the template
  • •(d) — actual attribute values are held by each object, not by the class, and the definition of behavior lives in the class rather than the object

Key rule: Class is to object as blueprint is to building: one definition, many instances, each instance with its own attribute values.

System Development Technology · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.