Saturday, May 11, 2019

what will happen when you run the following code?

Problem statement:
what is the output for the following code?
  1. class ExecutionTen {
  2.     public void talk() {}
  3. }
  4. public class ExecutionNine {
  5.     public static void main(String[] args) {
  6.         ExecutionTen t = null;
  7.         try {
  8.             t.talk();
  9.         } catch (NullPointerException e) {
  10.             System.out.println("This is NullPointerException !");
  11.         } catch (Exception e) {
  12.             System.out.println("This is an Exception !");
  13.         }
  14.         System.out.println("Everything went fine !");
  15.     }
  16. }
Output:
This is NullPointerException !
Everything went fine !

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...