Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
If you have methods as follows,
void someMethod( Base obj ); // 1
void someMethod( Level1_A obj ); // 2
void someMethod( Level1_B obj ); // 3
void someMethod( Level2_A obj ); // 4
and you invoke someMethod() with argument null, then you STILL have ambiguity because now the confusion is between invoking the Level1 method or the Level2 method i.e., between 3 & 4.
Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
Originally posted by Sharda Vajjhala:
In question 2, why doesn't it pick A? A being a user-defined class should be considered more specific than String or Object, right?
Thanks
Sharda
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
SCJP 1.4
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
I think the example given by Dan shows a bug in the compiler.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Originally posted by Jose Botella:
I think the example given by Dan shows a bug in the compiler.
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
The compiler can't resolve which one is more specific and this is true since you can't cast a Cat to BlackLabradorRetrieverPuppyThatIsSmallerThanOthers which is a Dog or BlackLabradorRetrieverPuppyThatIsSmallerThanOthers to a Cat.
SCJP2. Please Indent your code using UBB Code
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|