6. Control statements nested in loops Flashcards

1
Q

What is printed by the following code?
int x = 10;
int y = 20;
System.out.println(x + y > 30 ? x : y);

A

20.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the effect of the following code?
System.out.println();
System.out.println();
System.out.println();

A

ss

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do you think is the effect of the following code?

System.out.print(“”);

A

ss

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What limit is there on the nesting of statements within other statements?

A

There is no limit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
What is wrong with the following code?
int x = ...
int y = ...
if (x > y) {
  int large = x;
  int small = y;
} else {
  int large = y;
  int small = x;
}
System.out.println(large + " is greater than " + small);
A

ss

How well did you know this?
1
Not at all
2
3
4
5
Perfectly