SCIENCE.
Trusted by students across multiple disciplines!
What is an if statement? - Answer: The command that allows you to make a decision
based on true or false conditions
What is an else statement? - Answer: 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? - Answer: 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 break keyword used for? - Answer: Used to end the execution in the current
loop body.
How do you prevent fall through logic in a switch statement? - Answer: Using the break
keyword.
What is a Boolean expression? - Answer: An expression that can be evaluated as
either true or false
Else if statement - Answer: The most general way of writing a multi-way decision.
1. The expressions are evaluated in order.
2. If any expression is true, the block associated with it is executed and then it breaks
out of the chain of statements.
1
APPHIA - Crafted with Care and Precision for Academic Excellence.