A: Test t = newTest();
B: Test t = newTest(5);
C: Test t = newTest("5");
D: Test t = newTest(3.4);
举一反三
- 给出如下类定义: 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下列可以正确创建对象的格式是() A: Testt=1; B: Testt=newtest(); C: Testt=newtest; D: Testt=test();
- 如下代码定义了一个类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) { }}如果要创建一个该类的对象,正确的语句是:
- 中国大学MOOC: 给出如下类定义: public class Test { Test(int i) { } } 如果要创建一个该类的对象,正确的语句是( )。
内容
- 0
假设有类Test,下列可以正确创建对象的语句是( ) A: Test t=1; B: Test t=new Test(); C: Test t=new Test; D: Test t= Test();
- 1
设有泛型类的定义如下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>();
- 2
假定类Test已定义,test( )为Test类的公有成员函数,t为该类的一个对象,则通过t对象访问成员函数test( )的格式为( )。 A: t.test() B: t.test C: t->test() D: (*t).test()
- 3
设有泛型类的定义如下class Test; { }则由该类创建对象时,使用正确的是? A: Test; x = new Test;(); B: Test x = new Test(); C: Test; x = new Test;(); D: Test; x = new Test;();
- 4
定义类如下:class Test():def __init__(self,name):self.name=namedef show(self):print(self.name)下面代码能正常执行的是 ( ) A: t = Test('张三')t.show() B: t = Test()t.show('张三') C: t = Test()t.show() D: t = Testt.show('张三')