Skip to content
doubtly

What will be the output of the following Java program?

What will be the output of the following Java program?

  1.     class variable_scope 
  2.     {
  3.         public static void main(String args[]) 
  4.         {
  5.             int x;
  6.             x = 5;
  7.             {
  8. 	        int y = 6;
  9. 	        System.out.print(x + " " + y);
  10.             }
  11.             System.out.println(x + " " + y);
  12.         } 
  13.     }

a) Compilation error
b) Runtime error
c) 5 6 5 6
d) 5 6 5

Doubtly Asked Student doubt Save WhatsApp Report

1 answer

Your answer

Log in or create a free account to answer this question.