Having come late to the discussion, I am a bit behind things, but your last method won't work.
You are creating a new array, then iterating through it, then returning a number, which will be the last number in the array.
A new int[] array is filled with 0s by default, so that method will always return a 0.
Go through the
Integer class, and you find methods which will return their binary/octal/hexadecimal representation, but always without leading 0s.