SCJP Module-6 Question-18

The sample program given below will check your Knowledge about the Inheritance method overriding in Java and helps for the preparation of SCJP examination.

 
 

Share on Google+Share on Google+

SCJP Module-6 Question-18

Ads

The sample program given below will check your Knowledge about the Inheritance method overriding in Java and helps for the preparation of SCJP examination.

Given below the sample code :

class mainClass {
void process() throws Exception {
throw new Exception();
}
}

class sub extends mainClass {
void process() {
System.out.println("sub class");
}
}

class except {
public static void main(String[] args) {
mainClass m = new sub();
m.process();
}
}

What will be the output of the above code ?

1. No output

2. sub main

3. Compilation fails.

4. class sub

Answer

(3)

Advertisements

Posted on: July 15, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles