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

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

    Correct Answer: A, B

    Given the code, when an instance of the class 'Class' is created and initialized with the value 2, the instance 'Object' will have two attributes: 'prop' and 'var'. Therefore, the dictionary of the 'Object' instance (__dict__) will contain these two attributes, making the length of the dictionary 2, which makes A true. Since 'var' is an instance attribute, it will be present in 'Object.__dict__', making B true. The attribute 'data' is a class attribute and not an instance attribute, so it won't be present in 'Object.__dict__', but it will be in 'Class.__dict__'. Therefore, 'len(Object.__dict__) == 2' and 'var' in Object.__dict__ evaluate to True.

Discussion
kstr

Only A is True

DKAT2023

something wrong in the question