QuestionQ1

VerifiedObject-Oriented Programming

What is the expected outcome of the following code?

Question Image

Explanation

Double-underscore identifiers declared or referenced within a class are name-mangled. Both foo() calls update the shared _Class__Var, leaving it at 2; the first instance’s _Class__prop remains 1. Their sum is therefore 3.

Learn more

Community Discussion

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