QuestionQ30

VerifiedObject-Oriented Programming

Assuming the following code has executed successfully, which expressions evaluate to True?

Question Image

Choose two
Explanation

B inherits the get method from A, so hasattr(B, 'get') is True. C inherits B.get; the double-underscore reference inside that method is mangled to _B__VarA, which resolves to the value 2 defined on B. Therefore, obj_c.get() == 2 is also True.

Community Discussion

No comments yet. Be the first to start the discussion!