What is an object in object oriented programming?
A A source file
B A loop condition
C Instance of a class
D A processor instruction
Answer: C. Instance of a class. An object is a runtime instance that combines state and behavior.
What does a class define?
A A running process
B A sorted array
C Object structure and behavior
D A database connection
Answer: C. Object structure and behavior. A class describes fields and operations for its instances.
What is encapsulation?
A Converting code to machine language
B Sorting objects by address
C Bundling state with operations
D Calling a function recursively
Answer: C. Bundling state with operations. Encapsulation groups data with related methods and controls access to internal state.
What is abstraction?
A Showing essentials, hiding details
B Copying every object field
C Making every method public
D Repeating a class definition
Answer: A. Showing essentials, hiding details. Abstraction exposes useful behavior while hiding implementation details.
What does inheritance allow?
A An object changes its address
B A method runs in parallel
C A field becomes a constant
D A class derives from another
Answer: D. A class derives from another. Inheritance lets a derived class reuse or extend a base class.
What is a base class?
A Class with no methods
B Object's runtime copy
C A private field
D Class inherited from
Answer: D. Class inherited from. A base class supplies features that derived classes can inherit.
What is a derived class?
A A class with no fields
B Class inheriting another
C A compiled library
D A function parameter
Answer: B. Class inheriting another. A derived class inherits from another class and may add or override behavior.
What does a method represent?
A A memory address
B Operation associated with a class
C A stored database row
D A compiler setting
Answer: B. Operation associated with a class. A method defines behavior callable through a class or its object.
What is an instance field?
A Shared class behavior
B A loop variable only
C A global function
D Per object state
Answer: D. Per object state. Instance fields hold values associated with each object instance.
What is a class field commonly used for?
A Separate value per local variable
B Temporary method result
C State shared by class instances
D Object's private address
Answer: C. State shared by class instances. A class or static field belongs to the class rather than one instance.
What does a constructor usually do?
A Destroy a derived class
B Initialize a new object
C Sort a method list
D Override every method
Answer: B. Initialize a new object. A constructor establishes initial state when an object is created.
What is a default constructor?
A Constructor callable without arguments
B Constructor that deletes objects
C A method returning a class
D A constructor declared private always
Answer: A. Constructor callable without arguments. A default constructor can be invoked without supplying arguments.
What is a destructor used for?
A Create the first instance
B Overload an operator
C Declare an interface
D Release object resources
Answer: D. Release object resources. A destructor or finalization mechanism can release resources when an object is cleaned up.
What does a private member mean?
A Accessible everywhere
B Restricted to class implementation
C Accessible only to subclasses
D Stored outside the object
Answer: B. Restricted to class implementation. A private member is hidden from ordinary external access.
What does a public member mean?
A Accessible only inside class
B Accessible through public interface
C Never callable by objects
D Shared across all programs
Answer: B. Accessible through public interface. Public members form the externally accessible part of a class interface.
What does protected access commonly allow?
A Every program access
B No method access
C Only constructor access
D Class and derived class access
Answer: D. Class and derived class access. Protected members are typically accessible within the class hierarchy.
What is an object's state?
A Current field values
B Its class source file
C Its method names only
D The program's call stack
Answer: A. Current field values. The state of an object is represented by its current field values.
What is an object's behavior?
A Operations it can perform
B Its memory address only
C The order classes compile
D All global values
Answer: A. Operations it can perform. An object's behavior is expressed through its methods and responses.
What does message passing mean in OOP?
A Classes compile without files
B Objects share all fields
C Objects request behavior from others
D Methods run only at startup
Answer: C. Objects request behavior from others. Objects communicate by invoking methods or sending requests.
What does composition express?
A Strong whole part ownership
B A temporary method call
C A class name alias
D A sort order
Answer: A. Strong whole part ownership. Composition models a whole object containing parts it owns as a unit.
What is an association between classes?
A A type conversion rule
B A class compiler warning
C A constructor argument list
D Relationship between their objects
Answer: D. Relationship between their objects. An association represents a relationship between instances of classes.
What does an is a relationship usually suggest?
A Inheritance
B Composition
C Method overloading
D Data hiding only
Answer: A. Inheritance. An is a relationship can indicate that a subtype is a kind of its base type.
What does a has a relationship often suggest?
A Method overriding
B Composition or aggregation
C Recursion
D Static dispatch
Answer: B. Composition or aggregation. A has a relationship commonly describes an object containing or referencing another.
What is a class invariant?
A Method called once only
B Field without a type
C Condition that should remain true
D Object's memory size
Answer: C. Condition that should remain true. A class invariant is a rule that valid objects maintain across operations.
Why use accessors and mutators carefully?
A Preserve class invariants
B Make every field global
C Remove all constructors
D Disable polymorphism
Answer: A. Preserve class invariants. Controlled getters and setters can protect consistency and validation rules.