Multiple choice

What is the output of the following program? import static java.lang.System.out; class sample1 { int a; public static void main(String args[]) { System.out.println(a); a++; } }

  1. 0

  2. Error in the importing package

  3. Compile time error

  4. 1

  5. Both 2 and 3

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Correct choice System class is present in java.lang package. As it is a final class, it calls println() through static printstream object out, so we initially import static java.lang.System.out, which initially declares static object out.