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

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

    Correct Answer: A, C

    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
DKAT2023Option: A

sorry , only A is correct

DKAT2023Options: AB

A and B are corrects