public class Point {
private int x, y;
public Point(int x, int y) { this.x = x; this.y = y; }
public String toString() { return "(" + x + "," + y + ")"; }
}
System.out.println(new Point(3, 4));What is printed?
- Acheck_circle
(3,4)
- B
Point@<hash>
- C
3,4
- D
Compile-time error
Explanation
<code>println(Object)</code> calls <code>toString()</code>. The override returns "(3,4)".