Module 5: Control Flow Logic Flashcards
What is an if statement?
The command that allows you to make a decision based on true or false conditions
What is an else statement?
A statement that follows an if statement in which the contained code will be executed if the if condition is not true
What is a switch statement?
The switch statement is Java’s multiway branch statement. It provides an easy way to dispatch execution to different parts of your code based on the value of an expression. As such, it often provides a better alternative than a large series of if-else-if statements.
What is the brake keyword used for?
Used to end the execution in the current loop body
How do you prevent fall through logic in a switch statement?
Using the break keyword
What is a Boolean expression?
An expression that can be evaluated as either true or false
else if statement
The most general way of writing a multi-way decision.
- The expressions are evaluated in order.
- If any expression is true, the block associated with it is executed and then it breaks out of the chain of statements.
Conditional Operations
Computer algorithms that perform a test, then perform another operation based on the results of the test
< less than
<= less than or equal to
> greater than
>= greater than or equal
== equal to
!= not equal to
&& short-circuit AND
|| short-circuit OR