1. public class Test2 extends Test {
2.public static void main(String args[]) {
3.Test2 obj = new Test2();
4.final byte b = 10;
6.obj.name(b);
7.}
public static void name(short c) {
System.out.println(" short type from subclass.."+c);
}
}
public class Test {
public static void name(short c) {
System.out.println(" short type from superclass.."+c);
}
public static void name(byte c) {
System.out.println(" byte type from superclass.."+c);
}
}
The code at line number "6" "obj.name(b)" is giving error
ERROR:
The method name(short) is ambiguous for the type Test2 Why does the compiler considers widening conversion of byte to short in method invocation if there is a method in Superclass which can accept the byte as parameter?
if i remove "public static void name(short c) " from Subclass Test2, then it compiles correctly.
[ November 21, 2007: Message edited by: gurpreet singh ]