Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam PCAP topic 1 question 69 discussion

Actual exam question from Python Institute's PCAP
Question #: 69
Topic #: 1
[All PCAP Questions]

A class constructor (Choose two.)

  • A. can return a value
  • B. cannot be invoked directly from inside the class
  • C. can be invoked directly from any of the subclasses
  • D. can be invoked directly from any of the superclasses
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
kstr
5 months ago
The correct options are: A. A class constructor can return a value. In Python, the constructor method is usually named __init__, and while it is not required to return a value, it is possible to include a return statement within the __init__ method if needed. C. A class constructor can be invoked directly from any of the subclasses. Subclasses can call the constructor of their superclass using the super() function. This allows the initialization code in the superclass to be executed. So, the correct choices are A and C.
upvoted 1 times
Gvsl
4 months, 4 weeks ago
A is incorrect. A class constructor can only return the value 'None'. If you try something else you will receive the errors below. Please check. TypeError: __init__() should return None, not 'int' TypeError: __init__() should return None, not 'float' TypeError: __init__() should return None, not 'str' TypeError: __init__() should return None, not 'list' TypeError: __init__() should return None, not 'tuple' TypeError: __init__() should return None, not 'dict
upvoted 2 times
...
...
Gvsl
5 months, 4 weeks ago
Selected Answer: CD
D is correct ---Script--- class c2: def __init__(self): c1.__init__(self) print('C2 init') class c1(c2): def __init__(self): print('C1 init') c2_var=c2() ---Output--- C1 init C2 init
upvoted 1 times
...
Mikku123
8 months, 2 weeks ago
B & D.
upvoted 2 times
...
Senthorus
9 months, 3 weeks ago
Selected Answer: BC
I think it's true
upvoted 3 times
...
aferiver
1 year, 1 month ago
Selected Answer: CD
A class constructor cannot return a value and can be invoked directly from any subclass or superclass. Therefore, options B and A are incorrect. The correct answer is options C and D. Option C means that the class constructor can be invoked directly from any subclass. Option D means that the class constructor can be invoked directly from any superclass.
upvoted 1 times
Senthorus
9 months, 3 weeks ago
D is false. You can't call a constructor from any superclass
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...