• 2022-06-29
    下列方法定义中,方法头不正确的是( )。
    A: public int x( ){ ... }
    B: public static int x( double y ){ ... }
    C: void x( double d ) { ... }
    D: public static x( double a ){ ... }
  • D

    内容

    • 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&#91;&#93; 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)"的方法重载