Q.1 Which of the following is NOT a feature of Object-Oriented Programming?
Encapsulation
Polymorphism
Recursion
Inheritance
Explanation - Recursion is a programming technique but not a feature of OOP. Encapsulation, Polymorphism, and Inheritance are key OOP features.
Correct answer is: Recursion
Q.2 What is the main purpose of encapsulation in OOP?
To hide internal details of a class
To create multiple classes
To allow multiple inheritance
To enable recursion
Explanation - Encapsulation ensures that internal details of a class are hidden from outside, providing controlled access via methods.
Correct answer is: To hide internal details of a class
Q.3 Which of these is an example of polymorphism?
Method overloading
Class declaration
Variable assignment
Looping
Explanation - Polymorphism allows a function or method to have multiple forms. Method overloading and overriding are examples.
Correct answer is: Method overloading
Q.4 In OOP, what does 'inheritance' allow a class to do?
Derive properties and behaviors from another class
Hide internal data
Overload functions
Execute faster
Explanation - Inheritance allows a new class (child) to acquire the properties and methods of an existing class (parent).
Correct answer is: Derive properties and behaviors from another class
Q.5 Which access specifier allows members to be accessible only within the class they are declared?
private
public
protected
default
Explanation - Private members are accessible only within the class. Public members are accessible everywhere, and protected members are accessible in derived classes.
Correct answer is: private
Q.6 What is the term for creating a new object as a copy of an existing object?
Cloning
Inheritance
Polymorphism
Encapsulation
Explanation - Cloning is the process of creating an exact copy of an object, often implemented via a clone() method.
Correct answer is: Cloning
Q.7 Which of these is true about a constructor in OOP?
It initializes objects of a class
It destroys objects
It hides private members
It allows multiple inheritance
Explanation - A constructor is a special method used to initialize objects when they are created.
Correct answer is: It initializes objects of a class
Q.8 Which concept allows the same function to behave differently based on arguments?
Polymorphism
Encapsulation
Inheritance
Abstraction
Explanation - Polymorphism allows a function to have multiple forms, either through overloading or overriding.
Correct answer is: Polymorphism
Q.9 Which keyword is used in Java to inherit a class?
extends
implements
inherits
super
Explanation - In Java, the 'extends' keyword is used for class inheritance.
Correct answer is: extends
Q.10 What is an abstract class?
A class that cannot be instantiated
A class with all private members
A class with no methods
A class that stores only data
Explanation - Abstract classes cannot be instantiated directly and are used as base classes for other classes.
Correct answer is: A class that cannot be instantiated
Q.11 Which of the following is true about interfaces in OOP?
They provide only method declarations
They store object data
They inherit all methods from parent class
They cannot be implemented
Explanation - Interfaces contain only abstract methods (method signatures) without implementation. Classes implement interfaces to provide functionality.
Correct answer is: They provide only method declarations
Q.12 Which OOP principle helps in reducing software complexity by exposing only necessary details?
Abstraction
Inheritance
Encapsulation
Polymorphism
Explanation - Abstraction focuses on hiding unnecessary implementation details and showing only essential features.
Correct answer is: Abstraction
Q.13 Which operator is used in C++ to access members of an object through a pointer?
->
.
::
*
Explanation - In C++, the '->' operator is used to access members of an object using a pointer.
Correct answer is: ->
Q.14 Which of these describes multiple inheritance?
A class inherits from more than one class
A class has multiple constructors
A class has multiple private members
A class overrides methods
Explanation - Multiple inheritance allows a class to inherit from two or more classes, but some languages like Java do not support it directly for classes.
Correct answer is: A class inherits from more than one class
Q.15 Which term refers to reusing existing code in new programs?
Code reuse
Polymorphism
Abstraction
Encapsulation
Explanation - OOP promotes code reuse via inheritance and composition, allowing programmers to use existing code in new applications.
Correct answer is: Code reuse
Q.16 Which is NOT a valid type of polymorphism?
Compile-time
Runtime
Execution-time
Operator overloading
Explanation - Polymorphism occurs at compile-time (method overloading, operator overloading) and runtime (method overriding), but 'execution-time' is not a recognized type.
Correct answer is: Execution-time
Q.17 Which of the following can be used to restrict inheritance in Java?
final keyword
private keyword
abstract keyword
static keyword
Explanation - In Java, the 'final' keyword prevents a class from being extended (inherited).
Correct answer is: final keyword
Q.18 Which OOP concept is being used when a child class provides a specific implementation of a method from parent class?
Method overriding
Encapsulation
Abstraction
Interface
Explanation - Method overriding occurs when a child class provides a new implementation for a method already defined in the parent class.
Correct answer is: Method overriding
Q.19 Which of the following is true about static members in OOP?
They belong to the class rather than objects
They cannot be accessed outside the class
They require object instantiation to use
They are always private
Explanation - Static members are shared among all instances of a class and belong to the class itself.
Correct answer is: They belong to the class rather than objects
Q.20 Which term is used when a class contains objects of other classes as members?
Composition
Inheritance
Polymorphism
Abstraction
Explanation - Composition is a design technique where a class is composed of objects of other classes to achieve code reuse.
Correct answer is: Composition
Q.21 Which of the following statements is true about 'this' keyword in Java?
It refers to the current object
It refers to the parent class object
It is used to create a new class
It can be used to declare static methods
Explanation - 'this' keyword in Java is a reference to the current object whose method or constructor is being invoked.
Correct answer is: It refers to the current object
Q.22 Which of the following is an example of runtime polymorphism?
Method overriding
Method overloading
Operator overloading
Variable shadowing
Explanation - Runtime polymorphism is achieved using method overriding where the method call is resolved at runtime.
Correct answer is: Method overriding
Q.23 Which OOP concept is applied when only required details are shown to the user?
Abstraction
Encapsulation
Inheritance
Polymorphism
Explanation - Abstraction hides implementation details from the user and shows only essential features.
Correct answer is: Abstraction
Q.24 Which of the following is correct about a destructor in C++?
It cleans up when an object goes out of scope
It initializes an object
It is optional in Java
It provides method overloading
Explanation - A destructor is called automatically when an object is destroyed to free resources or perform cleanup.
Correct answer is: It cleans up when an object goes out of scope
Q.25 Which keyword is used to refer to the parent class in Java?
super
this
base
parent
Explanation - 'super' keyword in Java is used to refer to the immediate parent class object, often to access parent methods or constructors.
Correct answer is: super
