Default Robot Configuration
A program initializes a robot object using a no-parameter constructor that chains to a parameterized constructor to set a default status code.
What is printed when the following Java program is compiled and run?
class Robot {
private int code;
public Robot(int c) {
code = c;
}
public Robot() {
this(10);
}
public int getCode() {
return code;
}
}
public class QuestionTrace {
public static void main(String[] args) {
Robot r = new Robot();
System.out.print(r.getCode());
}
}
A
10
B
11
C
1
D
0
Question Leaderboard
Not enough data yet to show leaderboard.
