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

What is the expected behavior of the following code?

    Correct Answer: A

    The code demonstrates the use of a class attribute 'Var' and instance attributes 'var'. Upon creating each instance of the class (object_1 and object_2), the class attribute 'Var' is incremented by 1. Initially, 'Var' is 0. After creating object_1, 'Var' becomes 1. After creating object_2, 'Var' becomes 2. The instance attributes 'var' for object_1 and object_2 are set to 1 and 2 respectively. The print statement sums Class.Var (which is 2), object_1.var (which is 1), and object_2.var (which is 2). Hence, it outputs 2 + 1 + 2 = 5.

Discussion
DKAT2023Option: D

Class didn't take argument