A: public int x( ){ ... }
B: public static int x( double y ){ ... }
C: void x( double d ) { ... }
D: public static x( double a ){ ... }
举一反三
- 【单选题】下列方法定义中,方法头不正确的是() A: public static x(double a) B: public static int x(double y) C: void x(double d) D: public int x()
- 下列方法定义中,方法头不正确的是( ) A: public int x( ){ ... } B: public static int x( double y ){ ... } C: void x( double D: { ... } <br> <br>public static x( double a ){ ... }
- 在下列方法定义中,方法头不正确的是( )。 A: public int method( ){...} B: public static int method(double y){...} C: void method(double d){...} D: public static method(double a){...}
- 不能与该方法构成重载的方法是() public double fun(int x,double y){ return x + y; } A: public void fun(int x){ System.out.println("x * x="+(x*x)); } B: public void fun(int a, double b){ System.out.println("a +b ="+(a+b)); } C: public int fun(int x, int y,int z){ renturn (x+y+z); } D: public double fun(double x, int y){ return x * y ; }
- 以下是"public static void test(int x, int y)"的方法重载( ) A: public static void Test(int x) B: public static int test(int x, int y) C: public static void test(int y, int x) D: public static void test(int x, int y)
内容
- 0
如下A类的定义中,不可以使用new A( )创建对象的是 A: public class A { int x; double d; } B: public class A { int x; double d; public A(){ <br> } } C: public class A { int x; double d; public A(){ x = 1; d = 0.5; } } D: public class A { int x; double d; public A(int x,double d){ this.x = x;<br> this.d = d; } } E: public class A { int x; double d; public A(int x,double d){ this.x = x;<br> this.d = d; } public A( ){ <br> } }
- 1
请说出E类中【代码1】,【代码2】的输出结果。 interface A { double f(double x,double y); } class B implements A { public double f(double x,double y) { return x*y; } int g(int a,int b) { return a+b; } } public class E { public static void main(String args[]) { A a = new B(); System.out.println(a.f(3,5)); //【代码1】 B b = (B)a; System.out.println(b.g(3,5)); //【代码2】 } }
- 2
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)); } }
- 3
执行下列程序,输出结果为()。 public class B{ public static void main(String[] args) { int x = 5; double y = 10.5f; float z = (float)(x*y); System.out.println(z); } }
- 4
以下是"public static void test(int x, int y)"的方法重载