Home Tutorial Java Scjp Part6 SCJP Module-6 Question-16


Share on Google+Share on Google+
SCJP Module-6 Question-16
Posted on: July 14, 2010 at 12:00 AM
The Sample Java program given below will check you understanding about the Exception handling in Java and it also test how you will handle exceptions when it arises.

Given below the sample code :

public class A {
static void test() throws Error{
if (true) throw new AssertionError();
System.out.print("test ");
public static void main(String[] args) {
try { test(); }
catch (Exception ex) { System.out.print("exception "); }
System.out.print("end ");

What will be the out put of the following code ?

1. test    exception   end

2. exception     end

3. test

4.Gives compile error.




Above code will give uncaught exception as output. Since it is of type "error " so it should be handled by error class object.


Related Tags for SCJP Module-6 Question-16:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 14, 2010

Recommend the tutorial

Advertisements Advertisements