Multiple choice

What will be the output of the following code? class Shift { public static void main(String arg[]) { int a=64,b; b=a<<2; System.out.println(b); } }

  1. 16

  2. 256

  3. 32

  4. 128

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

Left shift operator (<<) multiplies by powers of 2. a << 2 shifts 64 left by 2 bits: 64 × 2^2 = 64 × 4 = 256. In binary: 64 = 1000000, shifting left gives 100000000 = 256. Each left shift doubles the value.