Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 30

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

    Correct Answer: A, C

    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
Dave304409Options: AB

is correct

DKAT2023Options: AB

A and B are corrects