Default Chaining
A class utilizes constructor chaining to set a default value when no arguments are provided.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
static class Item {
int code;
Item() {
this(100);
}
Item(int code) {
this.code = code;
}
}
public static void main(String[] args) {
Item i = new Item();
System.out.print(i.code);
}
}
A
0
B
100
C
1
D
null
Question Leaderboard
Not enough data yet to show leaderboard.
