下列代码的执行结果为: ()
public class Super {
public Integer getLength() { return new Integer(4); }
public Integer getLength(int base) {
return base + 4;
}
}
class Sub extends Super {
public Integer getLength() { return new Integer(5); }
public static void main(String[] args) {
Super superObj = new Super();
Sub subObj = new Sub();
System.out.println(superObj.getLength().toString() + "," +
subObj.getLength(2).toString() );
}
}
输出是什么?
A. 4,6
B. 4,5
C. 6,4
D. 编译失败.---------重定时不能改变返回类型
出自:国际开放大学Java语言程序设计