What is the output of the following code?
class Test { Test() { this(); int k = 10; // First statement System.out.println("b"); System.out.println("c"); } Test(int x) { System.out.println(x); } } public class Main { public static void main(String[] args) { new Test(); } }
this();//recursive constructor invocation
You cannot use this to call the constructor itself which will result in recursive constructor invocation.