Skip to main content

Q) what is the output of the fallowing java program?



//one.java
class  output
{
      public static void main( String args[])
     {
           int a;
          System.out.println(a);
     }
}

A)
The above  program has syntactical error.

-> Any variable declared in a method is known as “local variable” for local variable JVM does not give any default value.
->In the above example “a” is a local variable.
->Rule in java is that , we should not use local variable without giving some value to it.
->In java garbage value concept for unintialised variable is not there unlike “c”.

Comments