PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 100


What is true about Python class constructors? (Choose two.)

Show Answer
Correct Answer: CD

In Python, a class constructor is defined by the method __init__. This method initializes the object's attributes and is essential in creating class instances. Hence, the statement that the constructor is a method named __init__ is true. Additionally, the constructor must have at least one parameter, which is typically 'self.' This parameter refers to the instance being created, making it mandatory. Therefore, the constructor must include at least 'self' as a parameter, fulfilling the requirement of having at least one parameter.

Discussion

1 comment
Sign in to comment
macxszOptions: CD
May 4, 2022

C. the constructor is a method named __init__ D. the constructor must have at least one parameter <<<< at least it should have "self" parameter