• 2022-05-29
    设有泛型类的定义如下class Test; { }则由该类创建对象时,使用正确的是?
    A: Test; x = new Test;();
    B: Test x = new Test();
    C: Test; x = new Test;();
    D: Test; x = new Test;();
  • D
    本题目来自[网课答案]本页地址:https://www.wkda.cn/ask/tapyemtaoxtpjzo.html

    内容

    • 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; }