A: Test(){}
B: int Test(){}
C: Test(int x,int y,byte z){}
D: void Test(int x,int y,int z){}
举一反三
- 以下是"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)
- 以下是"public static void test(int x, int y)"的方法重载
- 给定Java代码如下所示,在横线处新增下列( )方法,是对cal方法的重载。public class Test{ public void cal(int x, int y, int z) { } }
- (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }
- 下面选项中,( )是合法的构造方法的重载ConstOver() { } A: protected int ConstOver() { } B: private ConstOver (int z, int y, byte x) { } C: public Object ConstOver (int x, int y, int z) {} D: public void ConstOver (byte x, byte y, byte z) { }
内容
- 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;