What will be displayed by the following code?

public class Test1 {
    public static void main(String args[]) {
        System.out.println( 5 ^ 6 & 3);
        // Hint:
        // 0 - 0000        // 5 - 0101
        // 1 - 0001        // 6 - 0110
        // 2 - 0010        // 7 - 0111
        // 3 - 0011        // 8 - 1000
        // 4 - 0100        // 9 - 1001        
    }
}
Explanation
This example uses bitwise operations. The order plays a role. The conjunction & has a higher priority than the exclusive OR ^

Слідкуй за CodeGalaxy

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

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