What is the output of the following?
public class Main { public static void main(String... args) { Integer integer = new Integer(4); System.out.print(integer.byteValue()); // w w w .j a v a2 s. com System.out.print("-"); int i = new Integer(4); System.out.print(i.byteValue()); } }
C.
Java does not allow calling a method on a primitive.
While autoboxing does allow the assignment of an Integer to an int, it does not allow calling an instance method on a primitive. Therefore, the last line does not compile.