Conditional/ Selection Structure Flashcards

1
Q

an IF structure is what type of selection structure?

A

Single-Selection Structure

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

Is it necessary to use curly braces when using a single-selection structure?

A

No, but it is good coding style.

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

What is an example of a double-selection structure?

A

If-else

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

What is the final “else” called in a if-else-if structure?

A

A trailing else block

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

TRUE with the AND operator

A

All conditions must be true.

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

FALSE with the OR operator

A

All conditions must be false

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

What is the difference between ‘&’ operator and ‘&&’ operator?

A

‘&’ is bitwise and will do both comparisons no matter if the first is true or false. ‘&&’ is the logical AND and will stop testing if first condition is false.

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

What is the BANG operator?

A

NOT (!)

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

How do you get TRUE for the bitwise operator?

A

Returns TRUE if both values are different

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

What are the other ways to say bitwise operator?

A

Logical XOR, EXCLUSIVE OR, (^)

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

What is a switch statement able to evaluate for?

A

Equality (==)

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

What data type can a switch statement NOT evaluate?

A

Floating numbers (decimals)

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

Can a String be evaluated with a switch statement?

A

Yes

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

What is typically the final line in a switch statement?

A

Default

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

What keyword is needed to exit a switch when the matching value is found?

A

break

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

What are two methods of data “range testing”

A

1) Inside the Fence

2) Outside the Fence

17
Q

Inside the Fence uses the ___ operator

A

AND (&&)

18
Q

Outside the Fence uses the ___ operator

A

OR (||)

19
Q

What is the Ternary operator?

A

A shorter way to code an if-else structure.

20
Q

Why is it called the Ternary operator?

A

There are THREE operands

21
Q

Syntax for the ternary operator

A

condition ? if true : if false;

22
Q

What is a disadvantage of nested if?

A

As the number of conditions (doors) increase, it becomes more difficult to follow.