QuestionQ101

VerifiedObject-Oriented Programming

Which of the following lines of code will work correctly when independently placed inside the inc() method so that the snippet outputs 3?

Question Image

Choose two
Explanation

self.prop is initialized to 1, and val is 2. Both self.put(self.prop + val) and self.put(self.get() + val) invoke the instance method with 3, updating self.prop to 3. Instance methods must be accessed through self in this context.

Community Discussion

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