This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Runtime / Compile Time Behaviour Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Runtime / Compile Time Behaviour
 
Similar Threads
instanceof Doubt again??
Var args ... explanation needed
Polymorphism in java???
Overloading
Printing an Object without casting!