Tracing Nested If Statements
Consider the following method.
public static void message(int a, int b, int c)
{
if (a < 10)
{
if (b < 10)
{
System.out.print("X");
}
System.out.print("Y");
}
if (c < 10)
{
if (b > 10)
{
System.out.print("Y");
}
else
{
System.out.print("Z");
}
}
}
What is printed as a result of the call message(5, 15, 5)?
A
XYZ
B
YY
C
Y
D
Z
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | hitrishabhatia | 2 | 3 | 0m 00s | 190 |
| #2 | kazvin.tjakradinata | 2 | 2 | 0m 54s | 146 |
| #3 | y.seong2027 | 2 | 2 | 0m 56s | 144 |
| #4 | lsj08030922 | 1 | 1 | 0m 00s | 100 |
| #5 | suhanakochhar006 | 1 | 1 | 0m 54s | 46 |
| #6 | tellabhinaya | 1 | 1 | 1m 31s | 9 |
| #7 | namansoin000 | 1 | 1 | 5m 29s | -229 |
| #8 | bommasam000 | 3 | 3 | 58m 37s | -3,217 |
Items per page:
10
1 – 8 of 8
APFIVE