Given a sample code:
1 public class Sample {
2 static int j=5;
3 public static void main(String args[]) {
4 while (j > 0) {
5 j--;
6 }
7 System.out.println(j);
}}
What will be the result of above code ?
(1) 1
(2) 0
(3) 4
(4) The program compilation fails because of line number 2.
(2)
The variable j gets initialized to zero and therefore while loop does not get executed.