| Author |
Can anyone tell the result of this code.
|
Srinivasa Raghavan
Ranch Hand
Joined: Sep 28, 2004
Posts: 1228
|
|
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 ]
|
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
|
 |
saran sadaiyappan
Ranch Hand
Joined: Dec 23, 2004
Posts: 39
|
|
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
Joined: Sep 28, 2004
Posts: 1228
|
|
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";}
|
 |
Sangita Mishra
Greenhorn
Joined: Jun 15, 2005
Posts: 22
|
|
|
Yes it will print long, long. As both int and long canbe converted to long and long is more specific than float and double.
|
 |
 |
|
|
subject: Can anyone tell the result of this code.
|
|
|