Given:
3. public class Main { 4. public static void main(String[] args) { 5. String s = ""; 6. if(Integer.parseInt("011") == Integer.parseInt("9")) s += 1; 7. if(021 == Integer.valueOf("17")) s += 2; 8. if(1024 == new Integer(1024)) s += 3; 9. System.out.println(s); 10. } }
What is the result?
D is correct.
On line 6, the parseInt()
method assumes a radix of 10 if a radix is not specified.
Line 7 is comparing an octal int to an int.
Line 8 is comparing an int to an Integer, and autoboxing converts the Integer to an int to do the comparison.