Examveda
Examveda

What is the result of the expression 1 << 3 in Java?

A. 8

B. 4

C. 2

D. 3

Answer: Option A

Solution(By Examveda Team)

The << operator in Java is known as the left shift operator.

It shifts the bits of the number on the left side of the operator to the left by the number of positions specified on the right side.

Each left shift by one position doubles the value of the number.

In this case, 1 << 3 shifts the bits of the number 1 to the left by 3 positions.

The binary representation of 1 is 0001.

After shifting left by 3 positions, it becomes 1000, which is 8 in decimal.

Therefore, the result of 1 << 3 is 8.

This Question Belongs to Java Program >> Operators

Join The Discussion

Comments ( 1 )

  1. Shining Star
    Shining Star :
    5 months ago

    ITS ANSWER IS NOT 15 ,BECAUSE ^ ---> IS XOR BITWISE OPERATOR ; ITS ANSWER IS : 1

Related Questions on Operators