Java程序设计习题集汉英.docx
- 文档编号:2362537
- 上传时间:2022-10-29
- 格式:DOCX
- 页数:37
- 大小:29.70KB
Java程序设计习题集汉英.docx
《Java程序设计习题集汉英.docx》由会员分享,可在线阅读,更多相关《Java程序设计习题集汉英.docx(37页珍藏版)》请在冰豆网上搜索。
Java程序设计习题集汉英
17—英语版Java程序设计习题集
Java程序设计习题集(双语)
Chapter1Question
1.Whichofthefollowingstatementsaretrue?
1)ThegarbagecollectionalgorithminJavaisvendorimplemented
2)Thesizeofprimitivesisplatformdependent
3)Thedefaulttypeforanumericalliteralwithdecimalcomponentisafloat.
4)YoucanmodifythevalueinanInstanceoftheIntegerclasswiththesetValuemethod
2.Whichofthefollowingarevalidstatements?
1)System.out.println(1+1);
2)inti=2+'2';
3)Strings="on"+'one';
4)byteb=255;
3.Whichofthefollowingstatementsaretrue?
1)Theinstanceofoperatorcanbeusedtodetermineifareferenceisaninstanceofaclass,butnotaninterface.
2)Theinstanceofoperatorcanbeusedtodetermineifareferenceisaninstanceofaparticularprimitivewrapperclass
3)Theinstanceofoperatorwillonlydetermineifareferenceisaninstanceofaclassimmediatelyaboveinthehierarchybutnofurtheruptheinheritancechain
4)Theinstanceofoperatorcanbeusedtodetermineifonereferenceisofthesameclassasanotherreferencethus
4.Whichofthefollowingarevalidstatements
1)publicclassMyCalcextendsMath
2)Math.max(s);
3)Math.round(9.99,1);
4)Math.mod(4,10);
5.Whichofthefollowingstatementsaretrue?
1)Abytecanrepresentbetween-128to127
2)Abytecanrepresentbetween-127to128
3)Abytecanrepresentbetween-256to256
4)Acharcanrepresentbetween-2x2pow162x2pow16-1
6.WhichofthefollowingarekeywordsorreservedwordsinJava?
1)if
2)then
3)goto
4)while
5)case
7.Whichofthefollowingarelegalstatements?
1)floatf=1/3;
2)inti=1/3;
3)floatf=1.01;
4)doubled=999d;
8.Whichofthefollowingstatementsaretrue?
1)Aninterfacecanonlycontainmethodandnotvariables
2)Interfacescannothaveconstructors
3)Aclassmayextendonlyoneotherclassandimplementonlyoneinterface
4)InterfacesaretheJavaapproachtoaddressingitslackofmultipleinheritance,butrequireimplementingclassestocreatethefunctionalityoftheInterfaces.
9.Whichofthefollowingarevalidstatements
1)publicclassMyCalcextendsMath
2)Math.max(s);
3)Math.round(9.99,1);
4)Math.mod(4,10);
Answer:
(ellipsis)
Chapter2.Question
1.Whichofthefollowingarelegalidentifiers
1)2variable
2)variable2
3)_whatavariable
4)_3_
5)$anothervar
6)#myvar
2.Youwanttoloopthroughanarrayandstopwhenyoucometothelastelement.BeingagoodjavaprogrammerandforgettingeverythingyoueverknewaboutC/C++youknowthatarrayscontaininformationabouttheirsize.Whichofthefollowingcanyouuse?
1)myarray.length();
2)myarray.length;
3)myarray.size
4)myarray.size();
3.Whatwillhappenwhenyouattempttocompileandrunthiscode?
publicclassMyMain{
publicstaticvoidmain(Stringargv){
System.out.println("Hellocruelworld");
}
}
1)Thecompilerwillcomplainthatmainisareservedwordandcannotbeusedforaclass
2)Thecodewillcompileandwhenrunwillprintout"Hellocruelworld"
3)Thecodewillcompilebutwillcomplainatruntimethatnoconstructorisdefined
4)Thecodewillcompilebutwillcomplainatruntimethatmainisnotcorrectlydefined
4.Whichofthefollowingstatementsaretrue?
1)Ifaclasshasanyabstractmethodsitmustbedeclaredabstractitself.
2)Allmethodsinanabstractclassmustbedeclaredasabstract
3)Whenappliedtoaclass,thefinalmodifiermeansitcannotbesub-classed
4)transientandvolatileareJavamodifiers
5.Whichofthefollowingarevalidmethods?
1)publicstaticnativevoidamethod(){}
2)publicstaticvoidamethod(){}
3)privateprotectedvoidamethod(){}
4)staticnativevoidamethod();
6.Whichofthefollowingstatementsaretrue?
1)Constructorscannothaveavisibilitymodifier
2)Constructorscanbemarkedpublicandprotected,butnotprivate
3)Constructorscanonlyhaveaprimitivereturntype
4)Constructorsarenotinherited
7.Whichofthefollowingstatementsaretrue?
1)staticmethodsdonothaveaccesstotheimplicitvariablecalledthis
2)Astaticmethodmaybecalledwithoutcreatinganinstanceofitsclass
3)Astaticmethodmaynotbeoverridentobenon-static
4)Astaticmethodmaynotbeoverloaded
8.WhichofthefollowingareJavakeywords?
1)sizeof
2)main
3)transient
4)volatile
Answer:
(ellipsis)
Chapter3.Question
1.Sortthefollowinglistintoreservedandnon-reservedwords:
for,do-while,Integer,int,implements,equals,Object,java,switch,break,test,code,goto.
2.Listallthekeywordsthatcanbeusedtodefinecontrolflowstatements.
3.ListthekeywordsreservedbyJavabutnotusedinJava2.
4.WhichwordisnotaJavakeyword?
a.integerb.doublec.floatd.default
5.Whichkeywordisnotusedtocontrolaccesstoaclassmember?
a.publicb.protectedc.privated.default
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 程序设计 习题集 汉英
![提示](https://static.bdocx.com/images/bang_tan.gif)