Answer to Question #299861 in C++ for yeahh

Question #299861

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 }


1
Expert's answer
2022-02-19T06:22:33-0500
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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog