Python OOPs Concepts
Python OOPs Concepts - Important Points
1. | What is the syntax to create a new instance of a class in Python? |
---|
A. object = ClassName()
B. object = new ClassName()
C. object = create ClassName()
D. object = instance ClassName()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The syntax to create a new instance of a class in Python is ClassName().
2. | Which keyword is used to define a method in a class in Python? |
---|
A. def
B. class
C. method
D. function
View Answer Discuss Work SpaceAnswer: option a
Explanation:
3. | What is the purpose of inheritance in object-oriented programming? |
---|
A. To reuse code and avoid duplication
B. To create new objects
C. To define variables in a class
D. To call methods from other classes
View Answer Discuss Work SpaceAnswer: option a
Explanation:
4. | What is polymorphism in object-oriented programming? |
---|
A. The ability of an object to take on many forms
B. The process of defining two methods with the same name in a class
C. The process of defining a variable in a class
D. The process of calling methods from other classes
View Answer Discuss Work SpaceAnswer: option a
Explanation:
5. | Which keyword is used to inherit from a superclass in Python? |
---|
A. super
B. inherit
C. extends
D. from
View Answer Discuss Work SpaceAnswer: option c
Explanation: