ExamVeda
Login
Home
1
What is encapsulation in object-oriented programming (OOP)?
Discuss
Answer & Solution
Answer: Option C
Solution:
Encapsulation involves hiding the internal implementation details of an object and exposing a controlled interface.
2
What is the main benefit of encapsulation?
Discuss
Answer & Solution
Answer: Option C
Solution:
Encapsulation enhances security by controlling access to data and methods of an object.
3
What is inheritance in OOP?
Discuss
Answer & Solution
Answer: Option B
Solution:
Inheritance allows objects to inherit attributes and methods from a parent class.
4
What is an abstract class in OOP?
Discuss
Answer & Solution
Answer: Option A
Solution:
An abstract class cannot be instantiated and often serves as a blueprint for other classes.
5
What is a method resolution order (MRO) in Python?
Discuss
Answer & Solution
Answer: Option D
Solution:
The method resolution order (MRO) determines the order in which base classes are searched for a method or attribute.
6
What is multiple inheritance in OOP?
Discuss
Answer & Solution
Answer: Option D
Solution:
Multiple inheritance involves inheriting attributes and methods from multiple base classes.
7
How is the super() function used in Python inheritance?
Discuss
Answer & Solution
Answer: Option B
Solution:
The super() function is used to call the constructor of the base class in a subclass.
8
What is method overloading in Python?
Discuss
Answer & Solution
Answer: Option A
Solution:
Method overloading involves defining multiple methods with the same name but different parameters.
9
What is method overriding in Python?
Discuss
Answer & Solution
Answer: Option B
Solution:
Method overriding involves defining a method in a subclass with the same name as in the base class to modify its behavior.
10
What is a metaclass in Python?
Discuss
Answer & Solution
Answer: Option C
Solution:
A metaclass is a class that defines the structure of other classes, serving as a class template.