Program Flow  «Prev 

Java Conditional Loops - Quiz

Each question is worth one point. Select the best answer or answers for each question.
 

1. Branches allow a Java program to:
Please select the best answer.
  A. Repeat a section of code over and over
  B. Alter the flow of execution and run one piece of code instead of another
  C. Simultaneously execute two sections of code at once


2. How do you execute multiple lines of code based on an if-else statement?
Please select the best answer.
  A. Place the code below the branch.
  B. Place the code in parentheses below the branch.
  C. Place the code in a compound statement below the branch.

3. What happens when a switch statement encounters a break statement?
Please select the best answer.
  A. The branch jumps to the next case statement.
  B. The branch is exited.
  C. The branch continues just below the break statement.


4. The code in the default section of a switch statement is called:
Please select the best answer.
  A. After executing the code in a case match
  B. Whenever there is a case match
  C. Whenever there is not a case match

5. The for loop is primarily used to:
Please select the best answer.
  A. Repeatedly execute a section of code
  B. Conditionally execute a section of code
  C. Branch to another section of code


Your score is 0.0