Java Method static method Question 2

Question

What is the output of the following code?

public class Main {
  private static int i = 0;
  private static int j = 0;

  public static void main(String[] args) {
    int i = 2;//ww w . java 2  s.  c  om
    int k = 3;

    {
      int j = 3;
      System.out.println("i + j is " + (i + j));
    }

    k = i + j;
    System.out.println("k is " + k);
    System.out.println("j is " + j);
  }
}


i + j is 5
k is 2
j is 0

Question

What is the output of the following code?

public class Main {
  boolean x;

  public static void main(String[] args) {
    Main a = new Main();
    System.out.println(a.x);
  }
}


false



PreviousNext

Related