What will be the result of compilation and execution of the following code:

public class Test {
    public static void main(String[] s){
        long c = 1;
        switch(c)
        {
            case 1: c = 3; break;
            case 3: c = 4; break;
        }
        System.out.println(c);
    }
}
Explanation
A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types, the String class (since JDK 7), and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer.

switch does not work with long.

( https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html )

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести