File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can anyone tell the result of this code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can anyone tell the result of this code." Watch "Can anyone tell the result of this code." New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can anyone tell the result of this code.