QuestionQ84

VerifiedObject-Oriented Programming

What behavior is expected from the following code?

Question Image

Explanation

Class.Var is incremented once for each of the two instances, so it becomes 2. The two instance attributes hold 1 and 2, respectively; therefore, the expression evaluates to 2 + 1 + 2, which is 5.

Community Discussion

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