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;
            case 1: c = 3; break;
            case 3: c = 4; break;
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
Зарегистрируйся сейчас
или Подпишись на будущие тесты