• 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

Reg. conversion in method calls

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is a question from Barry Boone's exam :

I am not clear as to how the "long" will be
converted to "double"
Is implicit casting allowed in method calls.
i.e conversion as below from left to right are done automatically

I was under the impression that only byte,short , char
if found will be implicitly converted to int
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Angela,
Yes! I remember reading in Patrick Naughton's book that implicit conversions are allowed in method parameters.
What I faintly recollect as an example for this concept from that book is..if you have a method that takes no parameters and an overloaded one that takes a double as it argument...and you call it with an int..the second constructor gets invoked.
What I guess is in this case there is no (double, float, int) constructor and hence the entire param list gets upgraded!
Hope this helps,
Shyam
[This message has been edited by Shyamsundar Gururaj (edited September 24, 2001).]
 
Water proof donuts! Eat them while reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic