2: Flow ControlHomepage  « Java5 Certification « 2: Flow Control

In this section we look at the different syntax we can use to affect the flow of logic through our programs. We start by looking at code to implement if and switch statements whilst identifying legal argument types for them. We then investigate the different types of loops available in java and the iterators and their usage within a loop. We will also look at how we can break from a loop, continue from within a loop and label a loop to continue execution from. We continue our study of flow control by looking at assertions and when, and when not, they should be used. We finish our certification lessons on flow control by looking at exceptions, handling exceptions and how to declare methods and overriding methods that throw exceptions. We also need to understand what happens to our code when an error or any type of exception occurs in a code fragment and what happens when particular exceptions occur.

Lets take a look at the points outlined at the Oracle Website for this part of the certification.

  • Section 2: Flow Control

    1. Develop code that implements an if or switch statement; and identify legal argument types for these statements.

    2. Develop code that implements all forms of loops and iterators, including the use of for, the enhanced for loop (for-each), do, while, labels, break, and continue; and explain the values taken by loop counter variables during and after loop execution.

    3. Develop code that makes use of assertions, and distinguish appropriate from inappropriate uses of assertions.

    4. Develop code that makes use of exceptions and exception handling clauses (try, catch, finally), and declares methods and overriding methods that throw exceptions.

    5. Recognize the effect of an exception arising at a specified point in a code fragment. Note that the exception may be a runtime exception, a checked exception, or an error.

    6. Recognize situations that will result in any of the following being thrown: ArrayIndexOutOfBoundsException, ClassCastException, IllegalArgumentException, IllegalStateException, NullPointerException, NumberFormatException, AssertionError, ExceptionInInitializerError, StackOverflowError or NoClassDefFoundError. Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programmatically.

2.1 If & Switch Statements

In our first lesson within this section we look at code to implement if and switch statements whilst identifying legal argument types for them.

2.2 Loop Statements

In this lesson we investigate the different types of loops available in java and the iterators and their usage within a loop. We will also look at how we can break from a loop, continue from within a loop and label a loop to continue execution from.

2.3 Using Assertions

This lesson shows the syntax, rules and correct usage of assertions.

2.4-2.6 All About Exceptions

In our final lesson of the section we look at exceptions, handling exceptions and how to declare methods and overriding methods that throw exceptions. We also need to understand what happens to our code when an error or any type of exception occurs in a code fragment and what happens when particular exceptions occur.

Related Java5 Tutorials

Beginning Java5 - Conditional Statements
Beginning Java5 - Loop Statements
Flow Control - Using Assertions
Flow Control - Exception Overview
Flow Control - Exception Handling
Flow Control - Declaring Exceptions

go to home page Java5 Tutor Homepage go to home page Top





All the Java5 Certification Flow Control lessons are listed below. Click a link to go to that lesson.


2: Flow Control

2.1 if & switch Statements

2.2 Loop Statements

2.3 Using Assertions

2.4-2.6 All About Exceptions