Hi JavaExperts

I have done few program in Java using Bit wise AND OR operator... But Not getting the proper output or May be I am doing something wrong
Can any body explain why I am getting output

class Bit
   public static void main(String args[])

12 for the following code ,but how? plz. explain

010 (decimal) is 1010 binary, 4 is 0100, or them together you get 1110 which is 14. Now I'm puzzled as well. Perhaps I need a cup of coffee.

10 = is an integer
010 = is an octal (base 8)

So 010 = 1000 in binary
1100 = 12

I think this is how it works at least :)

Yes, of course, (hits forehead). Octal. Thanks.

the best way to solve bitwise problem is write eveything in bits and perform the operation and after tat convert it into octal or decimal

Reminds me of my favourite trick question:

What will be the output from


he he - that's right! (and nicely presented) Let's see who else gets it ;-)

tell this "WRONG!" to my JDK. Maybe it ll accept it. I won't.

public class ASD{
	public static void main (String [] args){

C:\Users\HCL\Desktop>java ASD

What you have in your JDK is NOT what I posted. Try copy/paste from my original post. Trust me.

hahaha, that's tricky, it took me a bit XD