QuestionQ26

VerifiedObject-Oriented Programming

What is the expected outcome of the following code?

Question Image

Explanation

Variable is a class attribute and is incremented to 1. Since neither instance overrides Variable, accessing object_2.Variable resolves to that class attribute. object_1.value is its instance attribute and remains 0, so the expression evaluates to 1.

Community Discussion

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