publicclassX{publicobjectm(){objecto=newfloat(3.14F);objectoa=newobject[1];oa[0]=o;o=null;oa[0]=null;returno;}}Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?()A.Justafterline5.B.Justafterline6.C.Justafterline7.D.Justafterline8(thatis,ast

题目
publicclassX{publicobjectm(){objecto=newfloat(3.14F);objectoa=newobject[1];oa[0]=o;o=null;oa[0]=null;returno;}}Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?()

A.Justafterline5.

B.Justafterline6.

C.Justafterline7.

D.Justafterline8(thatis,asthemethodreturns).


相似考题
更多“publicclassX{publicobjectm(){objecto=newfloat(3.14F);objectoa=newobject[1];oa[0]=o;o=null;oa[0]=null;returno;}}Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?() ”相关问题
  • 第1题:

    publicObjectm(){11.Objecto=newFloat(3.14F);12.Object[]oa=newObject[1];13.oa[0]=o;14.o=null;15.returnoa[0];16.}WhenistheFloatobject,createdinline11,eligibleforgarbagecollection?()

    A.Justafterline13.

    B.Justafterline14.

    C.Neverinthismethod.

    D.Justafterline15(thatis,asthemethodreturns).


    参考答案:C
    ThecorrectanswertothisquestionisC.Theobjectisnevergarbagecollectedsimplybecausethemethodreturnsit.Thinkaboutit,themessagethatreceivestheobjectmightdependonitsoitmustbesurethattheobjectreceivedbythemethodwontbegarbagecollected.Onlyinthissituationalocalobjectwontbeeligibleforgarbagecollection.Otherwise,alocalobjectiseligibleforgarbagecollectionassoonasthemethodends.

  • 第2题:

    return o; O是代表什么呢?如果不返回O 会怎么样?

    friend ostream& 

    operator<<(ostream&o,const Vector&v){

    for(int i=0; i<v.size; i++){

    o << v.data[i] << ' ';

    }

    return o;

    }


    ostream& o //o 是ostream的一个引用
    你的函数定义了返回类型为ostream&,自然要返回o,否则无法编译。

  • 第3题:

    下面的程序会抛出什么异常类型? public class Test { public static void main(String[] args) { Object o = null; System.out.println(o.toString()); } }

    A.ArrayIndexOutOfBoundsException

    B.StringIndexOutOfBoundsException

    C.ClassCastException

    D.NullPointerException


    E

  • 第4题:

    publicclassX{publicobjectm(){objecto=newfloat(3.14F);objectoa=newobject[1];oa[0]=o;o=null;returnoa[0];}}Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection?()

    A.Justafterline5

    B.Justafterline6

    C.Justafterline7(thatis,asthemethodreturns)

    D.Neverinthismethod.


    参考答案:D

  • 第5题:

    下面的程序会抛出什么异常类型? public class Test { public static void main(String[] args) { Object o = null; System.out.println(o); } }

    A.ArithmeticException

    B.ArrayIndexOutOfBoundsException

    C.StringIndexOutOfBoundsException

    D.没有异常


    E