Error Handling in JAVA

Error Handling:

The following are keywords used in error handling:

■ catch : Declares the block of code used to handle an exception.

■ finally : Block of code, usually following a try-catch statement, which is
executed no matter what program flow occurs when dealing with an exception.

■ throw : Used to pass an exception up to the method that called this method.

■ throws : Indicates the method will pass an exception to the method that
called it.

■ try : Block of code that will be tried, but which may cause an exception.

■ assert : Evaluates a conditional expression to verify the programmer’s
assumption.

Flow Controls In JAVA

Flow Controls :

The following are keywords used to control the flow through a block of code:

■ break - Exits from the block of code in which it resides.
■ case - Executes a block of code, dependent on what the switch tests for.
■ continue - Stops the rest of the code following this statement from
executing in a loop and then begins the next iteration of the loop.
■ default - Executes this block of code if none of the switch-case
statements match.
■ do - Executes a block of code one time, then, in conjunction with the
while statement, it performs a test to determine whether the block should
be executed again.
■ else - Executes an alternate block of code if an if test is false.
■ for - Used to perform a conditional loop for a block of code.
■ if - Used to perform a logical test for true or false.
■ instanceof - Determines whether an object is an instance of a class,
superclass, or interface.
■ return - Returns from a method without executing any code that follows
the statement (can optionally return a variable).
■ switch - Indicates the variable to be compared with the case statements.
■ while - Executes a block of code repeatedly while a certain condition
is true.