Witscale Test Center

SCJP Objectives covered


SCJP Objectives covered

Section 2: Flow control, Assertions, and Exception

 

2.1 Write code using if and switch statements and identify legal argument types for these statements.

 

2.2 Write code using all forms of loops including labeled and unlabeled, use of break and continue, and state the values taken by loop counter variables during and after loop execution.

 

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

 

2.4 Recognize the effect of an exception arising at a specified point in a code fragment. Note: The exception may be a runtime exception, a checked exception, or an error (the code may include try, catch, or finally clauses in any legitimate combination).

 

2.5 Write code that makes proper use of assertions, and distinguish appropriate from inappropriate uses of assertions.

 

2.6 Identify correct statements about the assertion mechanism.

 

 

A computer program is a bunch of instructions. Every programming language has a way to control the execution of these instructions. Java provides flow control statements for sequential, conditional and iterative execution. This ability to control the flow of execution is extremely important when you write complex applications in Java. In this chapter, you will learn about the flow control statements, their syntax and use.

Besides regular program flow, you also need to consider any erroneous conditions that may arise in your program. Once you know them, you must decide what to do in such situations. Java provides you with exceptions and exception handling statements to control the program execution when errors occur. In this chapter, you will learn how exceptions are used to separate error handling from your main application code. Assertions are the new addition to Java language from jdk1.4. You will learn to use this debugging tool appropriately.  Specifically this chapter covers the second SCJP objective completely.