Exam:310-035Title:SunCertifiedProgrammerforJava2Platform1.4Ver:04.21.04Note:SectionAcontains147questions.SectionBcontains147questions.Thetotalnumberofquestionsis294.SectionAQUESTION1Given:1publicclassTest{2publicstaticvoidmain(Stringargs[]){3classFoo{4publicinti=3;5}6Objecto=(Object)newFoo();7Foofoo=(Foo)o;8System.out.println("i="+foo.i);9}10}Whatistheresult?A.i=3B.Compilationfails.C.AClassCastExceptionisthrownatline6.D.AClassCastExceptionisthrownatline7.Answer:AQUESTION2Whichtwocauseacompilererror?(Choosetwo)A.float[]=newfloat(3);B.floatf2[]=newfloat[];C.float[]f1=newfloat[3];D.floatf3[]=newfloat[3];E.floatf5[]={1.0f,2.0f,2.0f};F.floatf4[]=newfloat[]{1.0f.2.0f.3.0f};Answer:A,BTheF.statementisincorrect.Thefloatnumbersshouldbeseparatedwithcommasandnotdots.QUESTION3Given:1inti=1,j=10;2do{3if(i++>--j){4continue;5}6}while(i<5);7System.out.println("i="+i+"andj="+j);Whatistheresult?A.i=6andj=5B.i=5andj=5C.i=6andj=5D.i=5andj=6E.i=6andj=6Answer:DQUESTION4Given:1classTest{2privateDemod;3voidstart(){4d=newDemo();5this.takeDemo(d);6}78voidtakeDemo(Demodemo){9demo=null;10demo=newDemo();11}12}WhenistheDemoobject,createdonline3,eligibleforgarbagecollection?A.Afterline5.B.Afterline9.C.Afterthestart()methodcompletes.D.WhenthetakeDemo()methodcompletes.E.Whentheinstancerunningthiscodeismadeeligibleforgarbagecollection.Answer:EQUESTION5Given:1interfaceAnimal{2voidsoundOff();3}45classElephantimplementsAnimal{6publicvoidsoundOff(){7System.out.println("Trumpet");8}9}1011classLionimplementsAnimal{12publicvoidsoundOff(){13System.out.println("Roar");14}15}1617classAlpha1{18staticAnimalget(Stringchoice){19if(choice.equalsIgnoreCase("meateater")){20returnnewLion();21}else{22returnnewElephant();23}24}25}Whichcompiles?A.newAnimal().soundOff();B.Elephante=newAlpha1();C.Lion1=Alpha.get("meateater");D.newAlpha1().get("veggie").soundOff();Answer:DQUESTION6Whichstatementistrue?A.MemoryisreclaimedbycallingRuntime.gc().B.Objectsarenotcollectediftheyareaccessiblefromlivethreads.C.Objectsthathavefinalize()methodsarenevergarbagecollected.D.Objectsthathavefinalize()methodsalwayshavetheirfinalize()methodscalledbeforetheprogramends.E.AnOutOfMemoryerrorisonlythrownifasingleblockofmemorycannotbefoundthatislargeenoughforaparticularrequirement.Answer:BQUESTION7Given:1classA{2A(){}3}45classBextendsA{6}Whichtwostatementsaretrue?(Choosetwo)A.ClassB'sconstructorispublic.B.ClassB'sconstructorhasnoarguments.C.ClassB'sconstructorincludesacalltothis().D.ClassB'sconstructorincludesacalltosuper().Answer:B,DQUESTION8Given:1inti=1,j=10;2do{3if(i>j){4break;5}6j--;7}while(++i<5);8System.out.println("i="+i+"andj="+j);Whatistheresult?A.i=6andj=5B.i=5andj=5C.i=6andj=4D.i=5andj=6E.i=6andj=6Answer:DQUESTION9Whichstatementistrue?A.Assertionscanbeenabledordisabledonaclass-by-classbasis.B.Conditionalcompilationisusedtoallowtestedclassestorunatfullspeed.C.Assertionsareappropriateforcheckingthevalidityofargumentsinamethod.D.Theprogrammercanchoosetoexecuteareturnstatementortothrowanexceptionifanassertionfails.Answer:AQUESTION10Youwantaclasstohaveaccesstomembersofanotherclassinthesamepackage.Whichisthemostrestrictiveaccessthataccomplishesthisobjective?A.publicB.privateC.protectedD.transientE.defaultaccessAnswer:EQUESTION11Given:1intx=3;2inty=1;3if(x=y){4System.out.println("x="+x);5}Whatistheresult?A.x=1B.x=3C.Compilationfails.D.Thecoderunsw...