Free AMCAT OOP Concepts Questions and Answers 1 — Questions and Answers
Question 1: Which OOP concept allows a class to have multiple methods with the same name but different parameters?
- Inheritance
- Polymorphism (Correct answer)
- Encapsulation
- Abstraction
Correct answer: Polymorphism
Method overloading is a form of compile-time polymorphism where multiple methods can have the same name but different numbers or types of parameters. The compiler decides which method to call based on the arguments provided during the call.
Question 2: The mechanism of bundling data (attributes) and methods that operate on the data into a single unit is known as:
- Inheritance
- Polymorphism
- Encapsulation (Correct answer)
- Abstraction
Correct answer: Encapsulation
Encapsulation is a fundamental OOP principle that binds together the data and the functions that manipulate them. It also restricts direct access to some of an object's components, which is a key part of data hiding.
Question 3: Which concept allows a new class to acquire the properties and behaviors of an existing class?
- Inheritance (Correct answer)
- Composition
- Abstraction
- Polymorphism
Correct answer: Inheritance
Inheritance is a core OOP concept where a new class (subclass or derived class) is based on an existing class (superclass or base class). This promotes code reusability by allowing the subclass to use and extend the functionality of the superclass.
Question 4: Hiding complex implementation details and showing only the essential features of an object is known as:
- Encapsulation
- Inheritance
- Abstraction (Correct answer)
- Polymorphism
Correct answer: Abstraction
Abstraction focuses on hiding the internal complexity and exposing only the necessary functionalities. For example, when you drive a car, you only need to know how to use the steering wheel and pedals, not the complex mechanics of the engine.
Question 5: What is the primary purpose of a constructor in a class?
- To destroy an object.
- To initialize the state of a new object. (Correct answer)
- To perform a complex calculation.
- To copy an existing object.
Correct answer: To initialize the state of a new object.
A constructor is a special method that is automatically called when an object of a class is created. Its main purpose is to initialize the object's instance variables to appropriate initial values.
Question 6: In the context of OOP, what does the 'is-a' relationship represent?
- Composition
- Aggregation
- Association
- Inheritance (Correct answer)
Correct answer: Inheritance
The 'is-a' relationship is a hallmark of inheritance. For example, a 'Car' is a 'Vehicle', and a 'Dog' is an 'Animal'. This means the subclass is a specialized version of the superclass.
Question 7: Which of the following is NOT a fundamental concept of Object-Oriented Programming?
- Encapsulation
- Inheritance
- Procedural Calling (Correct answer)
- Polymorphism
Correct answer: Procedural Calling
Encapsulation, Inheritance, and Polymorphism (along with Abstraction) are the four main pillars of OOP. Procedural Calling is a characteristic of procedural programming, a different programming paradigm.
Which OOP concept allows a class to have multiple methods with the same name but different parameters?