单选题1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for ga

题目
单选题
1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for garbage collection?()
A

 After line 5.

B

 After line 9.

C

 After the start() method completes.

D

 When the takeDemo() method completes.

E

 When the instance running this code is made eligible for garbage collection.


相似考题
更多“单选题1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for ga”相关问题
  • 第1题:

    有如下程序: include using namespace std; class Demo { public:

    有如下程序: #include<iostream.h> using namespace std; class Demo { public: Demo(){ cout<<"default constructor\n";} Demo(const Demo &X){ cont<<"copy constructor\n";} }; Demo userCode (Demo b){Demo c(b);return c;} int main() { Demo a,d; cout<<"calling userCode()\n"; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo &x)被调用的次数分别是( )。

    A.1和1

    B.1和2

    C.2和3

    D.2和4


    正确答案:C
    解析:此题考查的是虚函数的应用。C++语言中,在创建一个对象时,会自动调用类的构造函数,所以语句“Demo a,d;”将调用函数Demo()两次。当一个对象作为实参传递给函数时,为初始化形参,要调用复制构造函数:在函数返回一个对象时调用复制构造函数。所以语句“d=userCode(a);”调用复制构造函数3次。

  • 第2题:

    有如下程序:includeusing namespace std;classDemo{public: Demo(){cont<<"default

    有如下程序: #include<iostream.h> using namespace std; class Demo { public: Demo(){ cont<<"default constructor\n";} Demo(const Demo &x){ cont<<"copy constructor\n";} }; Demo userCode(Demo b){Demo c(b);return c;} int main() { Demo a,d; cout<<"calling userCode()\n"; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo &x)被调用的次数分别是

    A.1和1

    B.1和2

    C.2和3

    D.2和4


    正确答案:C
    解析:本题考核构造函数的应用,有一定的深度。函数Demo()为构造函数,而Demo(constDemo&x)为复制构造函数。C++在创建一个对象时,会自动调用类的构造函数,所以语句“Demoa,d;”将调用函数Demo()2次。当一个对象作为实参传递给函数时为初始化形参,要调用拷贝构造函数;在函数返回一个对象时调用拷贝构造函数。由此可知语句“d=userCode(a);”调用复制构造函数3次。

  • 第3题:

    下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.test(5); de.test(6,8); } }

    A.No 5 6 8

    B.5 6 8 No

    C.No 5 14

    D.8 6 No 5


    正确答案:C
    解析:本题考查的是方法重载的概念及应用,本题中应顺调查用test(),test(5)和test(6,8)方法,所以答案为选项C)。

  • 第4题:

    以下程序调试结果为:

    public class Test {

    int m=5;

    public void some(int x) {

    m=x;

    }

    public static void main(String args []) {

    new Demo().some(7);

    }

    }

    class Demo extends Test {

    int m=8;

    public void some(int x) {

    super.some(x);

    System.out.println(m);

    }

    }

    A.5

    B.8

    C.7

    D.无任何输出

    E.编译错误


    正确答案:B

  • 第5题:

    1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for garbage collection?()  

    • A、 After line 5.
    • B、 After line 9.
    • C、 After the start() method completes.
    • D、 When the takeDemo() method completes.
    • E、 When the instance running this code is made eligible for garbage collection.

    正确答案:E

  • 第6题:

    定义一个jQuery插件函数正确的写法是()。

    • A、$.fn.demo=function(){}
    • B、$.exent("demo")
    • C、$.event="demo"
    • D、$.demo

    正确答案:A

  • 第7题:

    让id名为demo的元素以淡出的方式实现隐藏效果的正确写法是()。

    • A、$("#demo").animate({opacity:0},200)
    • B、$("#demo").fadeOut("fast")
    • C、$("#demo").animate({height:0},300)
    • D、$("#demo").fadeTo("fast",0)

    正确答案:A,B,D

  • 第8题:

    Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?() 

    • A、 import utils.*;
    • B、 static import utils.*;
    • C、 import utils.Repetition.*;
    • D、 static import utils.Repetition. *;
    • E、 import utils.Repetition.twice();
    • F、 import static utils.Repetition.twice;
    • G、 static import utils.Repetition.twice;

    正确答案:F

  • 第9题:

    单选题
    以下的程序的执行结果为? () public class Demo{  public double getHeight(){  return 171.0;  }  public int getHeight (){  return 171;  }  public static void main(String[] args){  Demo demo = new Demo();  System.out.println(demo.getHeight());  }  }
    A

    输出171.0

    B

    输出171

    C

    第2行和第5行编译报错

    D

    第10行编译报错


    正确答案: C
    解析: 暂无解析

  • 第10题:

    多选题
    改变class不为demo的div元素的背景色,以下哪些写法是错误的?()
    A

    $(div.demo).css(background,blue)

    B

    $(div:not(.demo)).css({background:blue})

    C

    $(div:not(.demo)).css({background,blue})

    D

    $(div:not(.demo)).css(background,blue)


    正确答案: C,D
    解析: 暂无解析

  • 第11题:

    单选题
    Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
    A

     import utils.*;

    B

     static import utils.*;

    C

     import utils.Repetition.*;

    D

     static import utils.Repetition. *;

    E

     import utils.Repetition.twice();

    F

     import static utils.Repetition.twice;

    G

     static import utils.Repetition.twice;


    正确答案: D
    解析: 暂无解析

  • 第12题:

    单选题
    Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
    A

    import utils.*;

    B

    static import utils.*;

    C

    importutils.Repetition.*;

    D

    static importutils.Repetition.*;

    E

    import utils.Repetition.twice();

    F

    import static utils.Repetition.twice;

    G

    static import utils.Repetition.twice;


    正确答案: A
    解析: 暂无解析

  • 第13题:

    有关类Demo,哪句描述是正确的( )?public class Demo extends Base{private int count;public Demo(){ System.out.println("A Demo object has been created");} protected void addOne() {count++; }}

    A.当创建一个Demo类的实例对象时,count的值为0。

    B.当创建一个Demo类的实例对象时,count的值是不确定的。

    C.超类对象中可以包含改变count 值的方法。

    D.Demo的子类对象可以访问count。


    正确答案:A

  • 第14题:

    有下列程序: include using namespace std; class Demo { public: Demo(){cout<<"d

    有下列程序: #include<iostream.h> using namespace std; class Demo { public: Demo(){ cout<<"default constmctor\n";} Demo(const Demo &x){ cont<<"copy constructor\n";} }; Demo userCode(Demo b){Demo c(b);return c;} int

    A.1和1

    B.1和2

    C.2和3

    D.2和4


    正确答案:C
    解析: 此题考查的是虚函数的应用。C++语言中,在创建一个对象时,会自动调用类的构造函数,所以语句“Demoa,d;”将调用函数Demo()两次。当一个对象作为实参传递给函数时,为初始化形参,要调用复制构造函数;在函数返回一个对象时调用复制构造函数。所以语句“d=userCode(a);”调用复制构造函数3次。

  • 第15题:

    下列程序的输出结果是 ( ) class Derao { void test() { Systeme.out.print("NO");} void test (int i) {System.out.print(a);} void test(int a,int b) {System.out.print(a+b);} } class Test { public static void main(String args[]) { Demo de=new Demo(); de.test(); de.test5.; de.test(6,8); } }

    A.No568

    B.568No

    C.No514

    D.86No5


    正确答案:C

  • 第16题:

    以下的程序的执行结果为? () public class Demo{  public double getHeight(){  return 171.0;  }  public int getHeight (){  return 171;  }  public static void main(String[] args){  Demo demo = new Demo();  System.out.println(demo.getHeight());  }  } 

    • A、输出171.0
    • B、输出171
    • C、第2行和第5行编译报错
    • D、第10行编译报错

    正确答案:C

  • 第17题:

    有一个类Demo,对与其构造方法的正确声明是()

    • A、void Demo(int x){…}
    • B、Demo(int x){…}
    • C、Demo Demo(int x){…}
    • D、int Demo(){}

    正确答案:B

  • 第18题:

    改变class不为demo的div元素的背景色,以下哪些写法是错误的?()

    • A、$("div.demo").css("background","blue")
    • B、$("div:not(.demo)").css({"background":"blue"})
    • C、$("div:not(.demo)").css({"background","blue"})
    • D、$("div:not(.demo)").css("background","blue")

    正确答案:A,C

  • 第19题:

    Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()

    • A、import utils.*;
    • B、static import utils.*;
    • C、importutils.Repetition.*;
    • D、static importutils.Repetition.*;
    • E、import utils.Repetition.twice();
    • F、import static utils.Repetition.twice;
    • G、static import utils.Repetition.twice;

    正确答案:F

  • 第20题:

    从页面的所有div元素中筛选出id名为demo的div元素,写法正确的是()。

    • A、$("div").has("#demo")
    • B、$("div").filter("#demo")
    • C、$("div").eq("#demo")
    • D、$("div").find("#demo")

    正确答案:B

  • 第21题:

    多选题
    让id名为demo的元素以淡出的方式实现隐藏效果的正确写法是()。
    A

    $(#demo).animate({opacity:0},200)

    B

    $(#demo).fadeOut(fast)

    C

    $(#demo).animate({height:0},300)

    D

    $(#demo).fadeTo(fast,0)


    正确答案: B,A
    解析: 暂无解析

  • 第22题:

    单选题
    从页面的所有div元素中筛选出id名为demo的div元素,写法正确的是()。
    A

    $(div).has(#demo)

    B

    $(div).filter(#demo)

    C

    $(div).eq(#demo)

    D

    $(div).find(#demo)


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    有一个类Demo,对与其构造方法的正确声明是()
    A

    void Demo(int x){…}

    B

    Demo(int x){…}

    C

    Demo Demo(int x){…}

    D

    int Demo(){}


    正确答案: D
    解析: 暂无解析