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

PCAP-31-03 Exam - Question 25


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

Show Answer
Correct Answer: AB

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

2 comments
Sign in to comment
DKAT2023Options: AB
Jun 29, 2024

A and B are corrects

Dave304409Options: AB
Jul 5, 2024

is correct