Home Tutorial Java Scjp Part2 SCJP Module-2 Question-4


Share on Google+Share on Google+
SCJP Module-2 Question-4
Posted on: July 7, 2010 at 12:00 AM
The program given below is will help you understanding of exception handling of java and also helpful for SCJP examination.

Find the Output Of the following Code:

1.  import java.io.*;
2.  public class Example4 {
3.  public static void main(String[] args) {
4.  Example4 e4 = new Example4();
5.  try{
6.  e4.check();}
7.  catch(IOException e){}}
8.  void check() throws IOException{
9.  System.out.println("Inside check() method of Class ");
10. throw new IOException();}}
11. class Subexample4 extends Example4 {
12. void check() {
13. System.out.println("Inside check() Method of Subclass");
14. }}

What will be the output of the following code snippet  :

(1) Above program will throw exception & will not run.

(2).Inside check() method of class

(3) Inside check() method of Subclass

(4)Inside check() method of class
    Inside check() method of Subclass.

Answer :


Explanation :

Because the "e4"object is the member of the main class , therefore it can call only the methods of the main class.







Related Tags for SCJP Module-2 Question-4:

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

Recommend the tutorial

Advertisements Advertisements