BooleansExpressionsConditionals Flashcards

1
Q

What is a boolean expression?

A

Also called a condition, expression that evaluates to true or false.

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

What is a conditional statement?

A

A conditional statement allows the
program to choose which statement
will be executed next.
Conditional statements are sometimes
called selection statements
Conditional statements give the
program the ability to make basic
decisions based on the evaluation of
a boolean expression, i.e. one that
evaluates to either true or false.
○ If something is true, do this.
○ If it is false, do that instead

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

What is a switch statement?

A

The switch statement evaluates an expression and attempts to match the
result to one of several possible cases.
● Each case specifies a value. If the value matches the result of the
expression specified in the switch statement, the statements within the
case are executed.
● The flow of control transfers to the statements(s) specified within the first
matching case, but may flow through to the next case.
○ This flow from one case to another may be intentional, but often is not.
○ A break statement is used to interrupt the flow and exit from the switch statement.
● switch and case are reserved words (like if, else, void) and may only be
used within switch statements.
The switch Statement

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

What is an example of a conditional operator?

A

The conditional operator returns a value.
The condition determines which of two expressions will be evaluated.
Both expressions must return a value of the same type.
int max = ( value1 > value2 ? value1 : value2 )
The Conditional Operator
If value1 is greater than value2,
return value1. If not, return value2.

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