public class Plain {
private int x = 5;
}
// ...
Plain p = new Plain();
String s = p.toString();
System.out.println(s.startsWith("Plain@"));What is printed?
- A
Plain@5
- B
Compile-time error
- Ccheck_circle
true
- D
false
Explanation
Without overriding, Object's toString returns the form ClassName@hash, so the string starts with "Plain@".