Multiple choice technology programming languages

What is the output of the following code when compiled and run? Select one correct answer. public class Question02 { public static void main(String[] args){ int j = 017; int i = (byte)j >> 2; //line 1 System.out.println(Integer.toBinaryString(i)); //line 2 } }

  1. Prints 3

  2. Error during compilation at line 1

  3. Prints 11

  4. Prints 0

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

017 is an octal literal in Java, equal to decimal 15. The (byte) cast doesn't change the value since 15 fits in a byte. Right-shifting 15 (binary 1111) by 2 positions gives 3 (binary 11). Integer.toBinaryString(3) outputs '11'.