Good day.
Studying java tests, I noticed some inconsistency. In the first question, "specify the output":
public class QTest { { System.out.print("1"); } public static void main(String[] args) { System.out.print("2"); new QTest(); } static { System.out.print("3"); } } the correct answer is "321", that is, after the static block follows the constructor call and, finally, the call to the non-staic block.
In the second question of a similar plan:
public class Test { { System.out.println("1"); } Test () { System.out.println("2"); } static { System.out.println("3"); } { System.out.println("4"); } public static void main(String[] args) { new Test(); } } the correct answer is "3142", that is, the call to non-static blocks precedes the call to the constructor. What could be the difference?
Thank you.