PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 93


What is the expected behavior of the following code?

Show Answer
Correct Answer: C

C

It raises an exception because there is no colon after Sub_B(Super)

Discussion

10 comments
Sign in to comment
deckmanOption: B
May 11, 2022

I guess there's a Typo Error. A Syntax error is not an Exception (you cannot do try: except on that).

Iamrandom
Jan 1, 2024

Sorry but it is. issubclass(SyntaxError, Exception) --> True

macxszOption: B
May 4, 2022

If text were right, answer is: B. it outputs 1 Otherwise it raises an exception because it has a typo.

EfrenOption: B
Nov 13, 2021

Answer is B. Infuriating to see that just missing a colon and whoever wrote this assume code is wrong.. >>> class Super: def make(self): return 0 def doit(self): return self.make() >>> class Sub_A(Super): def make(self): return 1 >>> class Sub_B(Super): pass >>> a=Sub_A() >>> b=Sub_B() >>> >>> >>> print(a.doit() + b.doit())

stuartz
Jun 15, 2022

One thing I've learned from doing these is to process like python does and check for syntax errors before doing anything else

JnanadaOption: B
Aug 19, 2022

If text were right, answer is: B. it outputs 1

Jos015Option: C
Nov 10, 2023

Always is C. You can fix "class SubB(Super):" and see the result in question nº 120 class Super: def make (self): pass def doit (self): return self.make() class Sub_A(Super): def make(self): return 1 class Sub_B(Super): pass a = Sub_A() b = Sub_B() print(a.doit() + b.doit()) TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

sadako11Option: B
Feb 16, 2022

Another question with a possible typo! Without the typo the answer is B.

Rizos
Mar 16, 2023

There are no indentation or typo issues in the exam!!!

andr3
Mar 19, 2023

did you pass the exam ?

ricoproOption: B
Jul 23, 2023

>>> class Super: ... def make(self): ... return 0 ... def doit(self): ... return self.make() ... >>> class Sub_A(Super): ... def make(self): ... return 1 ... >>> class Sub_B(Super): ... pass ... >>> a = Sub_A() >>> b = Sub_B() >>> print(a.doit() + b.doit()) 1 >>>

seaverickOption: C
Jan 21, 2024

#question 93 class Super: def make (self): return 0 def doit (self): return self.make() class Sub_A(Super): def make(self): return 1 class Sub_B(Super) pass a = Sub_A() b = Sub_B() print(a.doit() + b.doit()) Tested, right answer C (it raises an exception)