Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Originally posted by Scott Appleton:
Manfred, wouldn't a simple call to "test(i)" invoke the method in the subclass?
TryOne1.java:15: Reference to test is ambiguous. It is defined in void test(doub
le) and void test(int).
t.test(i);
AM<BR> <A HREF="mailto:anshulmohan@rediffmail.com" rel="nofollow">anshulmohan@rediffmail.com</A>
AM<BR> <A HREF="mailto:anshulmohan@rediffmail.com" rel="nofollow">anshulmohan@rediffmail.com</A>
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Originally posted by Ajith Kallambella:
Anshul,
In your case, the method [b]int test(int i) happens to be the most specific method that is accessible and hence it gets called. It is a simple case of method overloading.
If the method resolution results in an ambiguity because the compiler finds more than one applicable and accessible method, it generates an error.
Hope that helps!
[/B]
AM<BR> <A HREF="mailto:anshulmohan@rediffmail.com" rel="nofollow">anshulmohan@rediffmail.com</A>
AM<BR> <A HREF="mailto:anshulmohan@rediffmail.com" rel="nofollow">anshulmohan@rediffmail.com</A>
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |