• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Can anyone tell the result of this code.

 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi can anyone tell me, why following code prints float,float.

a. Prints: float,float b. Prints: float,double
c. Prints: double,float d. Prints: double,double
e. Compile-time error f. Run-time error
g. None of the above

Answer is float, float
[ June 23, 2005: Message edited by: Srinivasa Raghavan ]
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since is float is more specific than double it prints "float,float".Specific in the sense that float can take only float values...whereas double can take both float and double.

Hope I am right.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok So, if i add one more method that takes long, like the one below it should print long,long. Thanks saran.


static String m(long i) {return "long";}

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it will print long, long. As both int and long canbe converted to long and long is more specific than float and double.
 
please buy my thing and then I'll have more money:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic