Professional Documents
Culture Documents
CCS0023L
(Object Oriented Programming)
EXERCISE
8
Handling Java Exception and Assertion
Cognitive:
a) Know how to use handle exceptions using try-catch-finally constructs
b) Learn how to create existing and customized exceptions
c) Learn how to differentiate between checked and unchecked exceptions
d) Learn how to throw exceptions programmatically
Psychomotor:
a) construct a program to handle unusual conditions that interrupt the normal operation of
the program
b) compile and debug the error of the program
Affective
a) appreciate the concept behind this experiment
Exceptional conditions sometimes occur in properly written code and must be handled.
Exception handling in Java is build around the “throw-and-catch” paradigm.
All exceptions are objects of Throwable class. “try-catch()-finally” statement is the
exception handling mechanism of Java. “throw” statement manually creates an exception
or rethrows an exception, “throws” statement allows propagation of exception to the call
stack
III.EXPERIMENTAL PROCEDURE:
3. Create a Class FindArray that will try to iterate in the array displaying the content
in each index. The program should be able to catch an
ArrayIndexOutOfBoundsException, a NullPointerException and a
RunTimeException.
V. QUESTION AND ANSWER:
catch (Exception e) {
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________
2. Is there anything wrong with the following exception handler as written? Will this code
compile?
try {
} catch (Exception e) {
} catch (ArithmeticException a) {
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________
try {
} finally {
_____________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________
Topic Exception
Lab Activity No 8a
Lab Activity Arabic to Roman Numeral
Converter
CLO 1,3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL
Topic Exception
Lab Activity No 8b
Lab Activity Arabic Numbers to Word
Converter
CLO 1,3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL
Topic Exception
Lab Activity No 8c
Lab Activity FindArray
CLO 1,3
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL