• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic