Home Tutorial Java Scjp Part4 SCJP Module-4 Question-3

 
 

Share on Google+Share on Google+
SCJP Module-4 Question-3
Posted on: July 9, 2010 at 12:00 AM
Advertisement
The program given below checks you understanding of method overriding and exception handling in Java.

Given the following sample code:

class Example3{

void Twin(int a, float b) {

System.out.println("Hello ");}

}

class SubExample3 extends Example3{
public void Twin(int a, float b)throws java.io.IOException

{

System.out.println("Hello "); }

}

Choose the output of the above code :

1. Will run but gives no output

2. Compile error

3. Print 'Hello'

4. Ptint 'Hello' 'Hello'

Answer :

(2)

Explanation :

"IOException" is not compatible with "throws" clause .

Advertisement

Related Tags for SCJP Module-4 Question-3:


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

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com