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 Runtime / Compile Time Behaviour 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 "Runtime / Compile Time Behaviour" Watch "Runtime / Compile Time Behaviour" New topic
Author

Runtime / Compile Time Behaviour

Grant Malcom
Greenhorn

Joined: Nov 27, 2009
Posts: 1
Hi, EveryBody
Here is the Code , for Which i need some Explanation....

Now I get a Compile Error, at line# 13, Also, when the Method print with Integer Parameter is commented, then Program runs Fine, printing - String!, ( Why Not Object! was Printed )

Can Any one Explain the Behavior, is it anything to do with Runtime Polymorhisim.

Thanks in Advance!

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
wait....letme give you a link which will explain it to you
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
http://faq.javaranch.com/java/ScjpFaq#mostSpecific
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
so this means that between String and object, String will be chosen as String extends object....now even Integer extends Object so now compiler is confused whether to chose String or Integer so you get an ambiguous error

i hope this clears it all
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
sorry
its
http://faq.javaranch.com/java/ScjpFaq#mostSpecific
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime / Compile Time Behaviour