Given:Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?() A.move the line 12 print statement into the foo() methodB.change line 7 to public synchronized void go() {C.change the variable declaration on line 2 to private volatile int x;D.wrap the code inside the foo() method with a synchronized( this ) blockE.wrap the for loop code inside the go() method with a synchronized block synchronized(this){ //for loop code here }

Given:Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()

A.move the line 12 print statement into the foo() method

B.change line 7 to public synchronized void go() {

C.change the variable declaration on line 2 to private volatile int x;

D.wrap the code inside the foo() method with a synchronized( this ) block

E.wrap the for loop code inside the go() method with a synchronized block synchronized(this){ //for loop code here }


相关考题:

1.publicclasstest{2.publicstaticstringoutput=”3.4.publicstaticvoidfoo(inti){5.try{6.if(i==1){7.thrownewException();8.}9.output+=1”;10.}11.catch(Exceptione){12.output+=2”;13.return;14.}15.finally(16.output+=3”;17.)18.output+=4”;19.}20.21.publicstaticvoidmain(stringargs[])(22.foo(0);23.foo(1);24.25.)26.}Whatisthevalueofthevariableoutputatline24?()

1.publicclassTest{2.publicstaticStringoutput=””;3.4.publicstaticvoidfoo(inti){5.try{6.if(i==1){7.thrownewException();8.}9.output+=“1”;10.}11.catch(Exceptione){12.output+=“2”;13.return;14.}15.finally{16.output+=“3”;17.}18.output+=“4”;19.}20.21.publicstaticvoidmain(Stringargs[]){22.foo(0);23.foo(1);24.25.}26.}Whatisthevalueofthevariableoutputatline23?()

Given:When line 15 is reached, how many objects are eligible for the garbage collector?() A.0B.1C.2D.3E.4F.5

Given:Whenline14isreached,howmanyobjectsareeligibleforthegarbagecollector?() A.0B.1C.2D.3E.4

下列选项中,不能创建字典对象的语句是()。A.{'one':1, 'two':2, 'three':3}B.dict('one':1, 'two':2, 'three':3)C.dict([('one',1), ('two',2), ('three',3)])D.dict(zip(['one','two','three'], [1,2,3]))

执行下面的操作后,list_two的值为 list_one = [4,5,6] list_two = list_one list_one[2] = 3A.[4,5,6]B.[4,3,6]C.[4,5,3]D.A,B,C都不正确

执行以下操作后,list_two的值是: list_one=[4,5,6] list_two=list_one list_one[2]=3A.[4,5,6]B.[4,3,6]C.[4,5,3]D.都不对

4、下列选项中,不能创建字典对象的语句是()。A.{'one':1, 'two':2, 'three':3}B.dict('one':1, 'two':2, 'three':3)C.dict([('one',1), ('two',2), ('three',3)])D.dict(zip(['one','two','three'], [1,2,3]))

【单选题】执行以下操作后,list_two的值是: list_one=[4,5,6] list_two=list_one list_one[2]=3A.[4,5,6]B.[4,3,6]C.[4,5,3]D.都不对