ch6 Flashcards

1
Q

why Use if

A

to specify a block of code to be executed, if a specified condition is true

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

why use Use else

A

to specify a block of code to be executed, if the same condition is false

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

why use else if

A

Use else if to specify a new condition to test, if the first condition is false

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

how we can test for the condtion easily

A

variable = (condition) ? expressionTrue : expressionFalse;

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

the difference between if and the easy way

A

int time = 20;
String result;
result = (time < 18) ? “Good day.” : “Good evening.”;
System.out.println(result);

nt time = 20;
if (time < 18) {
  System.out.println("Good day.");
} else {
  System.out.println("Good evening.");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

else if =switch +break
if =switch -break
true or false

A

true

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

Loops

A

Loops
Loops can execute a block of code as long as a specified condition is reached.

Loops are handy because they save time, reduce errors, and they make code more readable.

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

Java While Loop

A

The while loop loops through a block of code as long as a specified condition is true:

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