Skip to main content

Checkpoint: two references, one object (then two)

Challenge on lesson: Checkpoint: MCQ with a state machine

CHALLENGE
Difficulty: advanced+25 XP

What is printed? ``java public class Box { private int v; public Box(int v) { this.v = v; } public void add(int x) { v += x; } public String toString() { return "" + v; } } Box b1 = new Box(5); Box b2 = b1; b2.add(3); b1 = new Box(10); b1.add(1); System.out.print(b1 + "/" + b2); ` Options: A. 11/8 B. 6/11 C. 8/11 D. 11/6` Print the letter, then why it is right and why each other option is wrong.

Back to lesson: Checkpoint: MCQ with a state machine