This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper Class.

 
Bhalotia Kunal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


can you please explain me which line makes a compile time error.

thanks,
Deepak
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you compile the code? What error message do you get? For what line?
 
Bhalotia Kunal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry,

The Answer is...
Compile-time error at 2.
Compile-time error at 4.

Thanks
Deepak
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ans:2 and 4

Why 2? Because the return type of intValue() is int and not Integer

Why 4?
parseType(String s)

In your example

Integer.parseInt(Integer.valueOf("1").intValue())

Integer.valueOf("1").intValue() return an int. But parseInt()
expects a String as argument so compiler error.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good. Now try it with the Java 5.0 compiler.

You will see that this is one of the mock exam questions that gets broken with Java 5.0.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic