Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper classes doubt?

 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

The below question is from Dan Chisholm's website,


Answer is given as K. I'm confused. Please help!
 
Vinayagar Karpagam
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could think of a problem only in line 5. But that too when I tried, there was no error and i could see .1e1d is taken as (.1 * pow(10,1)) = 1.0.
Similarly, .1e2d is treated as (.1 * pow(10, 2)) = 10.0.
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go thru' the below link:
3.10.2 Floating-Point Literals - JLS
 
Anuragk kushwaha
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi jothi,

no probs at all.......above code compile and run
with output
1) 1.0
2) 1.0
3) 1.0
4) 10.0
5) 1.0

because--->>

"All the wrapper classes except Character have two constructors -- one that takes the primitive value and another that takes the String representation of the value. For instance:"

Integer i1 = new Integer(50);
Integer i2 = new Integer("50");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic