Examveda
Examveda

What will be the output of the following Java program?
class variable_scope 
{
    public static void main(String args[]) 
    {
        int x;
        x = 5;
        {
      int y = 6;
      System.out.print(x + " " + y);
        }
        System.out.println(x + " " + y);
    } 
}

A. 5 6 5 6

B. 5 6 5

C. Runtime error

D. Compilation error

Answer: Option D


This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Related Questions on Data Types and Variables