A: Test; x = new Test;();
B: Test x = new Test();
C: Test; x = new Test;();
D: Test; x = new Test;();
举一反三
- 设有泛型类的定义如下class Test<T> { }则由该类创建对象时,使用正确的是? A: Test x = new Test();<table width="77" cellspacing="0" cellpadding="0"><colgroup><tbody><tr class="firstRow">数据添加到文件中; B: Test<int> x = new Test<int>(); C: Test<Object> x = new Test<Object>(); D: Test<T> x = new Test<T>();
- 如下代码定义了一个类Test: class Test { private int y; Test (int x) { y:x; } }现在为Test 类生成一个对象,正确的语句是( )。 A: Test t = new Test( ); B: Test t=new Test(10, 20); C: Test t; D: Test t=new Test(10);
- 给出如下类定义: public class test { test(int k) { } }如果要创建一个该类的对象,正确的语句是: A: test obj1 = new test('5 '); B: test obj1 = new test(5); C: test obj1 = new test(3.4); D: test obj1 = new test();
- 类test的定义如下,$x是类test的对象,则4个选项中,正确的是( )。class test{const no='110';}$x=new test( ); A: echo $x.no; B: echo $x->no; C: echo test->no; D: echo test::no;
- 假设有类Test,下列可以正确创建对象的语句是( ) A: Test t=1; B: Test t=new Test(); C: Test t=new Test; D: Test t= Test();
内容
- 0
(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(); } }
- 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
阅读程序 public class Test{ int x=12; public void method1(int x){ x+=x; System.out.println(x); } } 如果有如下的代码段: Test t=new Test(); t.method1(5); 程序执行到这个地方,代码输出结果是__________?
- 3
设有泛型类的定义如下 class Test { } 则由该类创建对象时,使用正确的是?
- 4
下列程序的输出结果是 _____ 。 #include using namespace std; class Test { public: Test() { cnt++; } ~Test() {cnt--; } static int Count() { returncnt;} private: static int cnt; }; int Test::cnt = 0; int main() { cout << Test::Count()<<' '; Test tl, t2; Test* pT3 = new Test; Test* pT4 = new Test; cout << Test::Count()<<' '; delete pT4; delete pT3; cout << Test::Count()<< endl; return 0; }