Java switch statement Question 1

Question

What is the output of the following code?

public class Main {
  public static void main(String args[]) {
    int verse = 2;

    switch (verse) {
    case 3:/*ww w.j  a v a 2  s. c o m*/
      System.out.print("A");
      System.out.println("B");
    case 2:
      System.out.print("C");
      System.out.println("D");
    case 1:
      System.out.print("E");
      System.out.println("F");
    }
  }
}


CD
EF

Note

The case has now break statement so it will fall through

System.out.print("E") will not add a new line after E.




PreviousNext

Related