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

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

    Correct Answer: A, B

    In the given code, the class A has a class variable VarA set to 1, and its instance variables are initialized in the __init__ method. Class B inherits from class A and has its own class variable VarA set to 2, but during initialization, it calls the superclass constructor using super().__init__(). This ensures that properties from class A are also initialized for instances of B. The expressions that evaluate to True are: A.VarA == 1, which checks the class variable VarA of class A, and isinstance(obj_b, A), which verifies if obj_b, an instance of class B, is also an instance of class A due to inheritance.

Discussion
DKAT2023Options: AB

A and B are corrects

Dave304409Options: AB

is correct