欢迎来到天天文库
浏览记录
ID:40558872
大小:27.64 KB
页数:16页
时间:2019-08-04
《java习题 - (给学生)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、例题1: Choosethethreevalididentifiersfromthoselistedbelow. A.IDoLikeTheLongNameClass B.$byte C.const D._ok E.3_case 例题2: Howcanyouforcegarbagecollectionofanobject? A.Garbagecollectioncannotbeforced B.CallSystem.gc(). C.CallSystem.gc(),passinginarefe
2、rencetotheobjecttobegarbagecollected. D.CallRuntime.gc(). E.Setallreferencestotheobjecttonewvalues(null,forexample). 例题3: Considerthefollowingclass: 1.classTest(inti){ 2.voidtest(inti){ 3.System.out.println(“Iamanint.”); 4.} 5.voidtest(Strings){ 6
3、.System.out.println(“Iamastring.”); 7.} 8 9.publicstaticvoidmain(Stringargs[]){ 10.Testt=newTest(); 11.charch=“y”; 12.t.test(ch); 13.} 14.} Whichofthestatementsbelowistrue?(Chooseone.) A.Line5willnotcompile,becausevoidmethodscannotbeoverridden.
4、 B.Line12willnotcompile,becausethereisnoversionoftest()thatrakesacharargument. C.Thecodewillcompilebutwillthrowanexceptionatline12. D.Thecodewillcompileandproducethefollowingoutput:Iamanint. E.Thecodewillcompileandproducethefollowingoutput:IamaString.
5、 例题4: Whichofthefollowinglinesofcodewillcompilewithouterror? A. inti=0; if(i){ System.out.println(“Hi”); } B. booleanb=true; booleanb2=true; if(b==b2){ System.out.println(“Sotrue”); } C. inti=1; intj=2; if(i==1
6、
7、j==2) System.out.println(“OK”
8、); D. inti=1; intj=2; if(i==1&
9、j==2) System.out.println(“OK”); 例题5: Whichtwodemonstratea"hasa"relationship?(Choosetwo) A.publicinterfacePerson{} publicclassEmployeeextendsPerson{} B.publicinterfaceShape{} publicinterfaceRectandleextendsShape{}
10、C.publicinterfaceColorable{} publicclassShapeimplementsColorable {} D.publicclassSpecies{} publicclassAnimal{privateSpeciesspecies;} E.interfaceComponent{} classContainerimplementsComponent{ privateComponent[]children; } 例题6: Whichstatementaboutthe
11、garbagecollectionmechanismaretrue? A.Garbagecollectionrequireadditionalprogramecodeincaseswheremultiple threadsarerunning. B.Theprogrammercanindicatethatareferencethroughalocalvariableisnolong
此文档下载收益归作者所有