Java Control Flow Knowledge Check

Java Control Flow Questions

Now that we have finished going over the section on Java Control Flow Statements, let’s test your knowledge with some questions. You can check your answers all the way down at the bottom.

  1. The most basic control flow statement in the Java programming language is the ____________ statement.
  2. The ____________ statement allows any number of possible execution paths.
  3. The ___________ statement is similar to the while statement, except it evaluates its expression at the ___________ of the loop.
  4. How do you write an infinite loop using the for statement?
  5. How do you write an infinite loop using the while statement?



Java Questions & Answers

Java Control Flow Answers

See if you answered the above questions correctly with the following answers.

  1. The most basic control flow statement in the Java programming language is the if-then statement.
  2. The switch statement allows any number of possible execution paths.
  3. The do-while statement is similar to the while statement, except it evaluates its expression at the bottom of the loop.
  4. How do you write an infinite loop using the for statement?
    for ( ; ; ) {
        //do something
    }
    
  5. How do you write an infinite loop using the while statement?
    while (true) {
        //do something
    }
    


Let’s move onto the next lesson in the series that discusses Java Classes.


Add a Comment

Your email address will not be published. Required fields are marked *