PCAP-31-03 Exam QuestionsBrowse all questions from this exam

PCAP-31-03 Exam - Question 30


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

Show Answer
Correct Answer: AC

In Python, constructors are defined using the `__init__` method. The first parameter of a class constructor (`__init__` method) is usually `self`, which refers to the instance being created, making the first option true. The constructor can indeed be invoked directly by calling `__init__`, though this is unconventional and generally reserved for specific circumstances, making the third option correct. Python does not implicitly call the super-class constructor during the constructor execution; it must be explicitly called using `super()`. Additionally, constructors in Python can use default values for parameters, which means the option stating the constructor can't use default values is incorrect.

Discussion

2 comments
Sign in to comment
DKAT2023Options: AB
Jun 29, 2024

A and B are corrects

Dave304409Options: AB
Jul 5, 2024

is correct