Q1.
What is inheritance in Object-Oriented Programming (OOP)?
1
1
The ability to define multiple methods with the same name
2
The ability of one class to derive properties and behaviors from another class
3
The process of restricting access to data members
4
The mechanism of wrapping data and methods into a single unit
Q2.
What is multilevel inheritance?
1
1
When a class inherits multiple classes
2
When a class inherits from a derived class
3
When multiple classes inherit a single base class
4
When a class does not inherit anything
Q3.
What are the types of polymorphism in OOP?
1
1
Static and Dynamic
2
Single and Multiple
3
Public and Private
4
Inheritance and Encapsulation
Q4.
Which of the following is an example of compile-time polymorphism?
1
1
Function Overloading
2
Function Overriding
3
Abstract Classes
4
Interfaces
Q5.
What is the difference between method overloading and method overriding?
1
1
Overloading is runtime polymorphism, overriding is compile-time polymorphism
2
Overloading happens in a subclass, overriding happens in the same class
3
Overloading occurs in the same class, overriding occurs in a derived class
4
Overloading requires inheritance, overriding does not
Q6.
What is the key feature of runtime polymorphism?
1
1
Method overloading
2
Dynamic method dispatch
3
Compile-time resolution
4
No inheritance required
Q7.
Which of the following statements about function overloading and function overriding is correct?
1
1
Function overloading occurs at runtime, while function overriding occurs at compile time
2
Function overloading requires inheritance, while function overriding does not
3
Function overloading is resolved at compile-time, while function overriding is resolved at runtime
4
Function overriding does not support dynamic binding
Q8.
Which statement is true about interfaces and abstract classes?
1
1
Interfaces can have constructors
2
Abstract classes cannot have concrete methods
3
An abstract class can have both abstract and concrete methods
4
Interfaces cannot be implemented by multiple classes
Q9.
What is Encapsulation in Object-Oriented Programming (OOP)?
1
1
Hiding the implementation details and exposing only the necessary functionality
2
Allowing direct access to all data members of a class
3
Writing all code in a single function
4
Using multiple inheritance to combine functionalities
Q10.
Which access specifier should be used to achieve Encapsulation in a class?
1
1
Private
2
Protected
3
Public
4
Static
Q11.
How can you modify private data members in a class while following encapsulation principles?
1
1
By declaring them as public
2
By using getter and setter methods
3
By using global variables
4
By using static methods only
Q12.
What is the main advantage of Encapsulation?
1
1
It makes the code less readable
2
It restricts reusability of code
3
It allows better control over data modification
4
It forces all data to be public
Q13.
Which of the following best describes Encapsulation?
1
1
Binding data and methods together
2
Allowing access to private variables from outside the class
3
Using multiple classes in a program
4
Inheriting properties from another class
Q14.
What is the primary difference between Encapsulation and Abstraction?
1
1
Encapsulation hides implementation details, while abstraction hides complexity
2
Encapsulation is not used in real-world applications, while abstraction is
3
Abstraction deals with private members only, while encapsulation does not
4
Encapsulation is only applicable to variables, while abstraction applies to methods
Q15.
What will happen if all the variables of a class are declared public?
1
1
It will violate the principle of Encapsulation
2
It will enhance data security
3
It will restrict object creation
4
It will make the program error-free
Q16.
Which of the following is an example of Encapsulation?
class BankAccount { private double balance; public void deposit(double amount) { balance += amount; } public double getBalance() { return balance; } }
1
1
The class is exposing all its data directly
2
The balance variable is hidden and access is controlled using methods
3
The balance variable is public and accessible from anywhere
4
The class does not follow encapsulation
Q17.
Which OOP principle is most closely related to abstraction?
1
1
Encapsulation
2
Inheritance
3
Polymorphism
4
None of the above
Q18.
What is the primary purpose of abstraction in Object-Oriented Programming (OOP)?
1
1
An abstract class can be instantiated
2
An abstract class cannot have constructors
3
An abstract class must have at least one abstract method
4
An abstract class can have both abstract and non-abstract methods
Q19.
What is the difference between abstraction and encapsulation?
1
1
Abstraction hides implementation details, while encapsulation protects data
2
Encapsulation is a subclass of abstraction
3
Abstraction protects data, while encapsulation hides implementation details
4
Both are the same
Q20.
Which of the following is an advantage of using abstraction?
1
1
Increased code reusability
2
Reduced complexity
3
Easier maintenance and scalability
4
All of the above