• 2022-06-06
    给出如下类定义: public class Test { Test(int i) { } } 如果要创建一个该类的对象,正确的语句是( )。
    A: Test t = newTest();
    B: Test t = newTest(5);
    C: Test t = newTest("5");
    D: Test t = newTest(3.4);
  • B

    内容

    • 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('张三')