What number sequence will be displayed at the output of the following program?
1 public class Confusing {
2 public static void method2() {
3 method1();
4 System.out.print("2");
5 }
6
7 public static void method3() {
8 method2();
9 System.out.print("3");
10 method1();
11 }
12
13 public static void method1() {
14 System.out.print("1");
15 }
16
17 public static void main(String[] args) {
18 method1();
19 method3();
20 method2();
21 method3();
22 }
23 }
public class Confusing {
public static void method2() {
method1();
System.out.print("2");
}
public static void method3() {
method2();
System.out.print("3");
method1();
}
public static void method1() {
System.out.print("1");
}
public static void main(String[] args) {
method1();
method3();
method2();
method3();
}
}
Output:
11231121231
Comments
Leave a comment