Professional Documents
Culture Documents
Exception 1
Week010 - Exception
Laboratory Exercise 009
Objective/s:
At the end of this activity, you should be able to:
· Demonstrate how Exceptions will be used
· Understand how to catch the exceptions
· Learn the advantage of exception handing in an application
Procedure:
Create a NetBeans project for this activity. The project name should be as follows:
Project Name: Lab009_<lastname_firstname>
Example: Lab009_Blanco_Maria
Compress the NetBeans project into .rar or .zip format and then upload to the link
provided in the LMS.
Only NetBeans project compressed in .rar or .zip format will be accepted.
Assessments
} finally {
System.out.println("4");
}
System.out.println("5");
}
}
C: Arithmetic exception
D: run perfectly
2: What needs to be done to remove the A: Make the catch clause catching Exception as the last catch
error in the class? clause
D: Nothing
B: It printed:
3
1
5
C: It printed:
Computer Programming 2
Exception 3
1
2
5
D: It printed:
5
Since it is correct to begin with.
Assessments
System.out.println("FINALLY");
}
}
}
C: It printed finally
D: Nothing happend
} catch (Exception1 e) {
throw e;
Computer Programming 2
Exception 5
}
}
}
6: What is the problem with the A: The finally statement must be preceeded by the
above code? catch clause
D: Nothing is wrong
7: What should be done with the A: Move the catch clause before the finally clause.
code?
B: Do not use Throwable as the supertype of
Exception 1.
D: Nothing is wrong
8: What happens after you have A: “Done” is printed and an exception is shown in
been able to fix the code? the stack
B: “Done” is printed
D: Nothing is wrong
Assessments
public class JavaApplication1 {
D: Nothing is wrong
Assessments