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

PCAP-31-03 Exam - Question 59


Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)

Show Answer
Correct Answer: AC

In this piece of code, class B inherits from class A, and class C inherits from class B. First, the option 'hasattr(B, 'get')' evaluates to True because class B defines a method named 'get'. Next, considering the inheritance chain, 'obj_c.get()' in class C will invoke the 'get' method of class B because C does not override it. The 'get' method in class B returns 'self.__VarA' which is 2, making 'obj_c.get() == 2' True. Therefore, the correct answers are 'hasattr(B, 'get')' and 'obj_c.get() == 2'.

Discussion

2 comments
Sign in to comment
DKAT2023Options: AB
Jul 12, 2024

A and B are corrects

DKAT2023Option: A
Jul 12, 2024

sorry , only A is correct