The output of your program is:
at Z.<init>(Test.java:12)
at Y.<init>(Test.java:3)
at Z.<init>(Test.java:12)
...
Till a certain no. of times.
Now your program is not running normally and the StackOverflowError has been raised and what you see above is the stack trace done by your JVM. To confirm that the StackOverflowError is raised you can do the following:
public static void main(
String s[])
{
System.out.println("Here it comes");
try
{
Z z=new Z();
}
catch(StackOverflowError e)
{
System.out.println("StackOverflowError encountered");
}
}
the output now prints - StackOverflowError encountered