Question 9
Back to Exercise
What is the output of the following Java program?
public class Main {
public static void main(String[] args) {
System.out.println(Integer.toBinaryString(13) + " " + Integer.toHexString(4095) + " " + Integer.parseInt("777", 8) + " " + Integer.parseInt("1111", 2) + " " + Integer.toString(255, 36) + " " + Long.toHexString(-1L).length());
}
}
- A 1101 fff 511 15 73 16 Correct
- B 1011 fff 511 15 73 16
- C 1101 FFF 511 15 ff 16
- D 1101 fff 777 15 73 8
Correct Answer: Option A
777 octal = 511; 255 in base 36 is "73" (7 × 36 + 3); -1L in hex is sixteen f's.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!