| preferred AP College board partner for AP classes
medium Solved by 15 students
Recursive Method Output
< Prev
Next >

What is the printed output when the program above executes?

public class Main {
    public static void printPattern(int n) {
        if(n < 1)
            return;
        printPattern(n - 1);
        System.out.print(n + " ");
    }
    public static void main(String[] args) {
        printPattern(4);
    }
}
A

4 1 3 2

B

1 2 3 4

C

1 3 2 4

D

4 3 2 1

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1hitrishabhatia11 0m 00s 100
#2sgarv251312 0m 00s 90
#3parth.taur22722 2m 51s 29
#4kazvin.tjakradinata13 1m 02s 18
#5lsj0803092202 0m 00s -20
#6y.seong202712 2m 00s -30
#7namansoin00001 0m 49s -59
#8suhanakochhar00613 3m 53s -153
#9bommasam000313 44m 35s -2,475
#10geethasailaja12 56m 09s -3,279
Items per page:
10
1 – 10 of 10

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy