public class A {
public A() {
System.out.print("hi ");
this(5);
}
public A(int n) {}
}
// ...What is the result?
- A
Nothing is printed
- B
Run-time error
- Ccheck_circle
Compile-time error: this(...) must be the first statement
- D
hi printed
Explanation
A call to this(...) (or super(...)) must appear as the very first statement of a constructor.