Control Flow  «Prev  Next»
Lesson 10

Java Statements Conclusion

Module summary

The following list summarizes the important points that were covered in this module:
  1. The if statement uses a boolean expression and the switch statement uses an int expression.
  2. The cases of a switch statement must be expressions that evaluate to int values (after promotion). The expressions must be able to be evaluated during compilation.
  3. Commas may be used to separate statements in the initialization and iteration parts of a for statement. If multiple statements are contained in the initialization part, then all variables that are declared in the initialization statements must be of the same type.
  4. The do statement executes the enclosed statement block at least once.
  5. The break statement terminates the enclosing loop or switch statement; the continue statement only terminates the current loop iteration.
  6. The throw statement throws objects that extend the Throwable class. The catch statement catches objects that extend the Throwable class.
  7. The finally clause is executed no matter whether an exception is thrown or caught.
  8. An object becomes eligible for garbage collection when it becomes unreachable. When or if an object is actually garbage collected, can not be predicted.

Key terms and concepts

  1. Statement block: A sequence of statements enclosed in brackets.
  2. If condition: The condition that is evaluated as part of an if statement
  3. Mutually exclusive: Either but not both.
  4. Exception: An object that signals that an abnormal event or error has occurred.
  5. Eligible for garbage collection: An object that is unreachable is eligible to be destroyed and have its resources reclaimed by the garbage collector.

Java Control Flow - Quiz

Click the Quiz link below to check your understanding of flow control and exception handling.
Java Control Flow - Quiz