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

 
 

Share on Google+Share on Google+
SCJP Module-6 Question-24
Posted on: July 15, 2010 at 12:00 AM
Advertisement
The program given below will check your understating about Exception in Core Java.

Given below the sample code :

class base{
public static void main(String[] argv) {
try {
argv = null;
argv[0] = "Check";
System.out.println(argv[0]);
} catch (Exception ex) {
System.out.println("General Exception");
} catch (NullPointerException npe) {
System.out.println("NullPointerException");
}}}

What will be the output of the above code ?

1.  Compilation error

2.  General Exception

3.  NullPointerException

4. General Exception
    NullPointerException 

Answer

(1)

Explanantion

It gives compilation error because it has unreachable catch block for NullPointerException. It is already handled by the catch block for Exception.
Advertisement

Related Tags for SCJP Module-6 Question-24:


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 15, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com