File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper Class.

 
Bhalotia Kunal
Greenhorn
Posts: 9
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic