About Question enthuware.ocpjp.v21.2.3343 :
Posted: Wed Jan 08, 2025 10:16 am
Identify examples of autoboxing.
[+] Integer i = 10;
[+] Integer getValue(){ return 2; }
[-] Long getValue(){ return 2; } - An int cannot be autoboxed into a Long. return 2L; would have been valid.
[+] System.out.println(2+"");
For some reason, the correct option is
However, we have excellent Java documentation (https://docs.oracle.com/javase/tutorial ... oxing.html), which says it all, quote:
[+] Integer i = 10;
[+] Integer getValue(){ return 2; }
[-] Long getValue(){ return 2; } - An int cannot be autoboxed into a Long. return 2L; would have been valid.
[+] System.out.println(2+"");
For some reason, the correct option is
Code: Select all
System.out.println(2+"");
Therefore, your item "System.out.println(2+"");" should be marked as INCORRECT.Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes.