📜 ⬆️ ⬇️

Friday task

All with friday!

We check knowledge and attention. Given Java code:

  1. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  2. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  3. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  4. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  5. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  6. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  7. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  8. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  9. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  10. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  11. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }
  12. public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main( String ... argv) { System. out .println(Foo.instance.x); } }

')
Attention question! What will be displayed? And most importantly - why?

UPD Caution - the correct answer is already in the comments. Please conduct a test in other PLs and provide the results in the comments.

Source: https://habr.com/ru/post/105764/


All Articles