AMCAT Object-Oriented Programming Concepts 1 — Questions and Answers
Question 1: Which OOP principle bundles data and methods that operate on that data within a single unit, restricting direct access from outside?
- Inheritance
- Polymorphism
- Encapsulation (Correct answer)
- Abstraction
Correct answer: Encapsulation
Encapsulation wraps data (attributes) and behavior (methods) together in a class and controls access through access modifiers like private, protected, and public.
Question 2: When a child class acquires the properties and behaviors of a parent class, this OOP concept is called:
- Polymorphism
- Encapsulation
- Abstraction
- Inheritance (Correct answer)
Correct answer: Inheritance
Inheritance allows a derived (child) class to reuse the fields and methods of a base (parent) class, promoting code reuse.
Question 3: Which of the following best describes polymorphism in OOP?
- A class can have only one constructor
- The same interface can be used for different underlying data types (Correct answer)
- A class cannot be instantiated
- All methods must be overridden
Correct answer: The same interface can be used for different underlying data types
Polymorphism means 'many forms' — the same method name or interface can behave differently depending on the object it operates on.
Question 4: What is an abstract class in object-oriented programming?
- A class with no attributes
- A class that can be directly instantiated
- A class that cannot be instantiated and may contain abstract methods (Correct answer)
- A class that inherits from multiple classes
Correct answer: A class that cannot be instantiated and may contain abstract methods
An abstract class serves as a blueprint for other classes; it cannot be instantiated on its own and may define abstract methods that subclasses must implement.
Question 5: Which of the following correctly distinguishes a class from an object?
- An object is a blueprint; a class is an instance
- A class is a blueprint; an object is an instance of that class (Correct answer)
- Classes and objects are the same thing
- An object can exist without a class
Correct answer: A class is a blueprint; an object is an instance of that class
A class defines the structure and behavior (blueprint), while an object is a concrete instance created from that class at runtime.
Question 6: Method overloading allows a class to define multiple methods with the same name but different:
- Return types only
- Access modifiers only
- Parameter lists (number or type of parameters) (Correct answer)
- Bodies only
Correct answer: Parameter lists (number or type of parameters)
Method overloading (compile-time polymorphism) requires methods to differ in their parameter list — either in the number, type, or order of parameters.
Question 7: In OOP, an interface is best described as:
- A class that has only private methods
- A contract specifying method signatures that implementing classes must define (Correct answer)
- A class that stores only static data
- A mechanism to restrict inheritance
Correct answer: A contract specifying method signatures that implementing classes must define
An interface defines a contract — it declares method signatures (and sometimes constants) without providing implementation, and any class that implements it must provide the bodies.
Which OOP principle bundles data and methods that operate on that data within a single unit, restricting direct access from outside?