If possible please suggest further improvement of the String class.Question 3:Given a link list, detect whether it's circular using only one loop.Tips: Below implementation is allowedfor( ... ){...}The following implementations is NOT allowed...for( ... ){...for( ... ) {...}}...or...for( p = list-head, q = list-head; p != NULL q != NULL; p = p-next ){...}...for( ... ){...}

If possible please suggest further improvement of the String class.

Question 3:

Given a link list, detect whether it's circular using only one loop.

Tips: Below implementation is allowed

for( ... )

{

...

}

The following implementations is NOT allowed

...

for( ... )

{

...

for( ... ) {...}

}

...

or

...

for( p = list->head, q = list->head; p != NULL && q != NULL; p = p->next )

{

...

}

...

for( ... )

{

...

}


相关考题:

Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()? A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”.C.Thecodecomiles.Butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.

publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?() A.Compilationfails.B.Compilationsucceedswitherrors.C.Compilationsucceedswithwarnings.D.Compilationsucceedswithoutwarningsorerrors.

Given:11.Stringtest=Thisisatest;12.String[]tokens=test.split(\s);13.System.out.println(tokens.length);Whatistheresult?() A.Anexceptionisthrownatruntime.B.1C.4D.Compilationfails.E.0

Given:11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+);15.}Whatistheresult?() A.Compilationfailsbecauseofanerrorinline13.B.AClassCastExceptionisthrownatruntime.C.123D.Compilationfailsbecauseofanerrorinline14.E.Compilationfailsbecauseofanerrorinline12.

Given:11.Stringtest=Thisisatest;12.String[]tokens=test.split(\s);13.System.out.println(tokens.length);Whatistheresult?() A.0B.1C.4D.Compilationfails.

Given:11.Stringtest=a1b2c3;12.String[]tokens=test.split(\\d);13.for(Strings:tokens)System.out.print(s+);Whatistheresult?() A.abcB.123C.a1b2c3D.a1b2c3

Given:String[]elements={for,tea,too};Stringfirst=(elements.length0)?elements[0]:null;Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thevariablefirstissettonull.D.Thevariablefirstissettoelements[0].

Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatline2,compile?()A.0B.1C.2D.3E.4

--Did you look up the time of the high-speed trains to Guangzhou --Yes, the early train is _____________ to leave at 3 : 00 p.m.A.aboutB.likelyC.dueD.possible

Some astronomers contend that the universe may be younger than previously believed.A:predictB:argueC:thinkD:suggest