请说出E类中【代码1】,【代码2】的输出结果并分析原因。class A { double f(double x,double y) { return x+y; }}class B extends A { double f(int x,int y) { return x*y; }}public class E {public static void main(String args[]) { B b=new B(); System.out.println(b.f(3,5)); //【代码1】 System.out.println(b.f(3.0,5.0)); //【代码2】 }}
请说出E类中【代码1】,【代码2】的输出结果并分析原因。class A { double f(double x,double y) { return x+y; }}class B extends A { double f(int x,int y) { return x*y; }}public class E {public static void main(String args[]) { B b=new B(); System.out.println(b.f(3,5)); //【代码1】 System.out.println(b.f(3.0,5.0)); //【代码2】 }}
发布时间:2024-10-24 10:51:35