1. Home
  2. Computing & Technology
  3. Computer Certification

Question 17

What is the result when you compile and run the following code?

 

public class ThrowsDemo

{ 

            static void throwMethod()

            { 

                          System.out.println("Inside throwMethod."); 

                          throw new IllegalAccessException("demo"); 

            }

 

            public static void main(String args[])

            { 

                       try

                        { 

                                    throwMethod(); 

                        }

                        catch (IllegalAccessException e)

                        { 

                                    System.out.println("Caught " + e); 

                       } 

            } 

} 

 

 

Compilation error Runtime error
Compile successfully, nothing is printed. Inside throwMethod. followed by caught: java.lang.IllegalAccessExcption: demo

Back to beginning
| Next Question



Explore Computer Certification
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Computer Certification

©2009 About.com, a part of The New York Times Company.

All rights reserved.