Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 11 students

Recursive Method Output

Mark
< Prev
Next >

Consider the following class definition.

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);
    }
}

What is printed as a result of executing the main method?

A

4 1 3 2

B

4 3 2 1

C

1 3 2 4

D

1 2 3 4

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1hitrishabhatia11 0m 00s 100
#2sgarv251312 0m 00s 90
#3Potter1611 0m 20s 80
#4busemagngr11 0m 21s 79
#5parth.taur22722 2m 51s 29
#6kazvin.tjakradinata13 1m 02s 18
#7lsj0803092202 0m 00s -20
#8y.seong202712 2m 00s -30
#9chunxiangxu.cxu01 0m 41s -51
#10charliecao12115901 0m 48s -58
Items per page:
10
1 – 10 of 15

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|