• 2022-06-16
    已有如下程序: public class Test{ public Test(int x,int y,int z){.....} } 下面哪些方法是合法的构造方法重载:( )
    A: Test(){}
    B: int Test(){}
    C: Test(int x,int y,byte z){}
    D: void Test(int x,int y,int z){}
  • A,C

    内容

    • 0

      中国大学MOOC: 如下所示的Test类的Java程序中,共有几个构造方法()。 public class Test{ private int x; public Test(){} public void Test(int i){ this.x=i; } public Test(String str){} }

    • 1

      (06-03)在Java中,以下程序编译运行后的输出结果为( )。 public class Test { int x, y; Test(int x, int y) { this.x = x; this.y = y; } public static void main(String[] args) { Test pt1, pt2; pt1 = new Test(3, 3); pt2 = new Test(4, 4); System.out.print(pt1.x + pt2.x); } }

    • 2

      using System; class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); } }

    • 3

      请说出下列程序错在哪里?给出具体原因。 public class Test { public static void method(int x) { } public static int method(int y) { return y; } }

    • 4

      下面是关于结构类型与变量的定义语句,错误的是________。 A: struct test{int a; int b; int c;}; struct test y; B: struct test{ int a; int b; int c;} struct test y; C: struct test{ int a; int b; int c;} y; D: struct { int a; int b; int c;} y;