public class test1 { public static int add(int a, int b) { return a+b; } public static double add(double a, double b) { return a+b; } ________________ ___________________ { ________________ ___________________ } public static void main(String[] args) { System.out.println("调用add方法:"+add(2.1,3.4,4.5)); } }
举一反三
- 中国大学MOOC: public class Test{ public static void main(String[ ] args) { int result =???; System.out.println(result); } public static int operate(double a, int b) { return 10*(int)(a+b); } public static int operate(int a, double b) { return 100*(int)(a+b); } public static int operate(double a, double b) { return 1000*(int)(a+b); }}???处填入( )时,编译程序会出错。
- 以下程序运行结果是 public class Test { public static void main(String[] args) { int a=1,b[]={2}; add(a); add(b); System.out.println(a+","+b[0]); } static int add(int x){ x++; return x; } static void add(int[] x){ x[0]++; } }
- 关于下列代码说法正确的是( ) public class Foo{ public int add(int a,int b){ return a+b; } public static void main(String[] args){ Foo foo = null; System.out.println(foo.add(10,20)); } }
- E类中System.out.println的输出结果是__________、________________。interface Com{int add(int a,int b);}abstract class A{abstract int add(int a,int b);}class B extends A implements Com{public int add(int a,int b){return a+b;}}public class E{public static void main(String args[ ]){B b=new B();Com com=b;System.out.println(com.add(12,6));A a=b;System.out.println(a.add(10,5));}}
- 以下代码运行后输出的内容( )public class Main { public static double div(int a, int b) { return (double)a/b; } public static int div(int a, int b) { return a/b; } public static void main(String[] args) { System.out.println(div(5, 2)); } } A: 2.5 B: 2 C: 输出内容不确定 D: 程序错误,无法运行