Classes and objects

Two counters start independently. Predict both values after calling increment twice on the first counter.

Examples

Example 1

Input
first = 2, second = 5
Expected output
4, 5

Example 2

Input
first = 0, second = 0
Expected output
2, 0

Hints and solution

Hint 1

Track each instance in a separate row.

Reveal worked answer

Two increments add 2 to the first instance’s field. The second instance’s field keeps its initial value.

Back to the lesson