• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mock question doubt about "autoboxing" - objective 3.1

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question taken from SCJP exam guide, page 272 chapter 3...Given:

1.class Convert {
2.public static void main (String[] args) {
3.Long xL = new Long(456L);
4. long x1 = Long.valueOf("123");
5.Long x2 = Long.valueOf("123");
6.long x3 = xL.longValue();
7.Long x4 = xL.parseLong();
8.Long x5 = Long.parseLong("456");
9. long x6 = Long.parseLong("123");
10.}
11.}

which will compile using Java 5, but will NOT compile using Java 1.4?
Answers are - Line 4, Line 7 and Line 8. "Becuase of the methods return types, these method calls required autoboxing to compile."

I am not sure wat to do with autoboxing to compile the code?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
clue:
remember what is autoboxing.
notice what those methods or constructor calls returns? (primitives/objects)
notice the corresponding reference variable type.
 
reply
    Bookmark Topic Watch Topic
  • New Topic