Discussion Forum : Operators
Question -


What is the output of this program?


class rightshift_operator {
public static void main(String args[])
{
int x;
x = 10;
x = x >> 1;
System.out.println(x);
}
}
Options:
A .  10
B .  5
C .  2
D .  20
Answer: Option B

Right shift operator, >>, devides the value by 2.
output:
$ javac rightshift_operator.java
$ java rightshift_operator
5



Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *