What is output of System.out.println(5|4)

5

  
Showing Answers 1 - 10 of 10 Answers

prasanta

  • Jan 6th, 2006
 

binary of 5=101

binary of 4=100

5 |4=         -----101=5

  Was this answer useful?  Yes

sambasiva

  • Dec 7th, 2006
 

 It gives 1 as output.

gmanon

  • Feb 3rd, 2010
 

Interesting question. 
It's easy to asume that you will get a boolean 1. Or perhaps, the compiler will give you the first number choosing between one or another. 

I do not know why, but running a test, it will give me a pattern of nonpair numbers.
 
I got this output:
~/JAVA$ javac testing.java; java testing
five, and cero:
5
five, and five:
5
five, and four:
5
five, and three:
7
five, and seven:
7
five, and eight:
13
five, and ten:
15
five, and twelve:
13
five, and thirteen:
13
five, and twenty:
21
five, and thirty:
31

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions