| preferred AP College board partner for AP classes
medium Solved by 7 students
If Statement Without Braces
< Prev
Next >

What is the output of the above code, and why?

public class SwapTest {
    public static void main(String[] args) {
        int x = 3, y = 5;
        if(x > y)
            x = y;
            y = x;
        System.out.println(x + " " + y);
    }
}
A

Compilation error

B

5 5

C

3 3

D

3 5

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1hitrishabhatia14 0m 00s 70
#2kazvin.tjakradinata12 0m 58s 32
#3y.seong202712 1m 36s -6
#4jebaksar00001 0m 44s -54
#5bommasam00016 2m 31s -101
#6isaact.taylor5201 1m 50s -120
#7namansoin00001 4m 00s -250
#8suhanakochhar00614 8m 56s -466
Items per page:
10
1 – 8 of 8

AI Tutor

How can I help?

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