Python Programming - Objects
Exercise : Objects - General Questions
- Objects - General Questions
1.
Which of the following is the correct way to create an object?
Answer: Option
Explanation:
In Python, objects are created using the
object() constructor.
2.
What is the purpose of the
__init__ method in a Python class?
Answer: Option
Explanation:
The
__init__ method is used to initialize the attributes of a class when a new object is created.
3.
What is the role of the
self parameter in Python class methods?
Answer: Option
Explanation:
The
self parameter in class methods refers to the instance of the class on which the method is called.
4.
In Python, how can you access the attributes of an object?
Answer: Option
Explanation:
The attributes of an object in Python are accessed using the dot notation:
object.attribute.
5.
What happens when you call the
del statement on an object's attribute?
Answer: Option
Explanation:
The
del statement removes an attribute from an object in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers