public class Demo{
public static void main(String args[])
{ Sub sb = new Sub( );
System.out.println(sb.method1( ));
}
}
class Super{
int x=1 , y=2;
public int method1(){
return ((x<y)?x:y);
}
}
class Sub extends Super{
public int mothod1( )
{
return ((x>y)?x:y);
}
}
结果是什么?为什么会得到这个结果?
朋友,你也被这道题坑了,父类那个方法跟子类的是不一样的,我当时以为两个一样。。。
追答哈哈,是的,真是醉了,文字游戏啊!