menu

Python OOPs Concepts

Python OOPs Concepts - Important Points


21. What is inheritance in Python?

A. The process of creating a new class from an existing class

B. The process of deleting a class

C. The process of creating an object from a class

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Inheritance in Python is the process of creating a new class from an existing class.

22. Which keyword is used to inherit from a class in Python?

A. parent

B. base

C. extend

D. None of the above

Discuss Work Space

Answer: option d

Explanation:

The keyword "class" is used to define a new class, while inheritance is achieved by specifying the parent class in parentheses after the class name.

23. What is method overriding in Python?

A. The process of defining a new method in a subclass with the same name as a method in the parent class

B. The process of deleting a method in a subclass

C. The process of creating a new method in a subclass with a different name than a method in the parent class

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Method overriding in Python is the process of defining a new method in a subclass with the same name as a method in the parent class.

24. Which method is called when an object is compared to another object in Python?

A. eq

B. cmp

C. ne

D. lt

Discuss Work Space

Answer: option a

Explanation:

The method "eq" is called when an object is compared to another object in Python using the == operator.

25. What is encapsulation in Python?

A. The process of hiding the implementation details of a class from its users

B. The process of exposing the implementation details of a class to its users

C. The process of creating a new class from an existing class

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Encapsulation in Python is the process of hiding the implementation details of a class from its users.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now