Java switch statement Question 2

Question

What is the output of the following code?


public class Main {
  public static void main(String args[]) {
    int x = 3;/*  w  ww.j a v a  2  s  .  c o m*/
    int y = 3;
    switch (x + 3) {
    case 6:
      y = 1;
    default:
      y += 1;
    }

    System.out.println(x);
    System.out.println(y);
  }
}


3
2



PreviousNext

Related