What is method overriding in Python?
A. Replacing a method with a new method
B. Defining a method in a subclass with the same name as in the base class
C. Calling a method from a different class
D. Creating a new method in a subclass
Answer: Option B
Solution(By Examveda Team)
Method overriding involves defining a method in a subclass with the same name as in the base class to modify its behavior.What is encapsulation in object-oriented programming (OOP)?
A. Exposing internal details of an object
B. Grouping data and methods into a single unit
C. Hiding data and methods within an object
D. Inheriting from multiple classes
What is the main benefit of encapsulation?
A. Improved code readability
B. Faster execution
C. Enhanced security
D. Better memory management
A. Creating new objects from existing ones
B. Allowing objects to share attributes and methods
C. Restricting access to object attributes
D. Converting classes into objects
What is an abstract class in OOP?
A. A class that cannot be instantiated
B. A class with no attributes
C. A class with only attributes
D. A class that cannot have methods
Join The Discussion