电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

(完整版)面向对象编程基础习题及答案VIP免费

(完整版)面向对象编程基础习题及答案_第1页
1/34
(完整版)面向对象编程基础习题及答案_第2页
2/34
(完整版)面向对象编程基础习题及答案_第3页
3/34
第1页共34页面向对象编程基础习题及答案PartI.ChoiceQuestions(1ptforeachquestion).1.Toaddatobandstoreresultinb,youwrite(Note:Javaiscase-sensitive)A.b+=a;B.a=b+a;C.b=A+b;D.a+=b;2.TodeclareaconstantPI,youwriteA.finalstaticPI=3.14159;B.finalfloatPI=3.14159;C.staticdoublePI=3.14159;D.finaldoublePI=3.14159;3.Toimprovereadabilityandmaintainability,youshoulddeclare_________insteadofusingliteralvaluessuchas3.14159.A.variablesB.methodsC.constantsD.classes4.Todeclareanintvariablexwithinitialvalue200,youwriteA.intx=200L;B.intx=200l;C.intx=200;D.intx=200.0;5.Toassignadoublevariabledtoanintvariablex,youwriteA.x=(long)dB.x=(int)d;C.x=d;D.x=(float)d;6.InJava,thewordtrueis________.A.aJavakeywordB.aBooleanliteralC.sameasvalue1D.sameasvalue07.WhichoftheBooleanexpressionsbelowhasincorrectsyntax?A.(true)&&(3>4)B.!(x>0)&&(x>0)C.(x>0)||(x<0)D.(x!=0)||(x=0)8.Whichofthefollowingisthecorrectexpressionthatevaluatestotrueifthenumberxisbetween1and100orthenumberisnegative?A.11))||(x<0)C.((x<100)&&(x>1))&&(x<0)D.(1>x>100)||(x<0)9.Whichofthefollowingisthecorrectexpressionofcharactera?A.'a'B."a"C.'\000a'D.Noneoftheabove.10.Whichofthefollowingstatementprintssmith\exam1\test.txt?A.System.out.println("smith\exam1\test.txt");B.System.out.println("smith\\exam1\\test.txt");C.System.out.println("smith\"exam1\"test.txt");D.System.out.println("smith"\exam1"\test.txt");11.Supposeiisaninttypevariable.WhichofthefollowingstatementsdisplaythecharacterwhoseUnicodeisstoredinvariablei?A.System.out.println(i);B.System.out.println((char)i);C.System.out.println((int)i);D.System.out.println(i+"");12.TheUnicodeof'a'is97.WhatistheUnicodefor'c'?A.96B.97C.98D.9913.Whichofthefollowingisaconstant,accordingtoJavanamingconventions?A.MAX_VALUEB.TestC.readD.ReadInt14.Whichofthefollowingassignmentstatementsisillegal?A.floatf=-34;B.intt=23;C.shorts=10;D.floatf=34.0;15.AJavastatementendswitha__________.A.comma(,)B.semicolon(;)C.period(.)D.closingbrace16.TheassignmentoperatorinJavais__________.A.:=B.=C.==第3页共34页D.<-17.Supposemandrareintegers.WhatisthecorrectJavaexpressionform/r^2toobtainafloatingpointresultvalue?(r^2denotesrraisedtothepowerof2).A.m/r*rB.m/(r*r)C.1.0*m/r*rD.1.0*m/(r*r)18.Whichofthesedatatypesrequirestheleastamountofmemory?A.floatB.doubleC.shortD.byte19.Whichofthefollowingoperatorshasthehighestprecedence?A.castingB.+C.*D./20.Anintvariablecanhold__________.A.'x'B.93C.98.3D.trueE.aandb21.Whichofthefollowingassignmentstatementsiscorrecttoassigncharacter5toc?A.charc='5';B.charc=5;C.charc="5";D.charc="344";22.NotethattheUnicodeforcharacterAis65.Theexpression"A"+1evaluatesto________.A.66B.BC.A1D.Illegalexpression23.ThenotequalcomparisonoperatorinJavais__________.A.<>B.!=C.!==D.^=24.Ifyouattempttoaddanint,abyte,along,andadouble,theresultwillbea__________value.A.byteB.int;C.long;第4页共34页D.double;25.Whatisthevalueof(double)5/2?A.2;B.2.5;C.3;D.2.0;26.Whatisthevalueof(double)(5/2)?A.2;B.2.5;C.3;D.2.0;27.Analyzethefollowingcode.publicclassTest{publicstaticvoidmain(String[]args){intmonth=09;System.out.println("monthis"+month);}}A.Theprogramdisplaysmonthis09B.Theprogramdisplaysmonthis9C.Theprogramdisplaysmonthis9.0D.Theprogramhasasyntaxerror,because09isanincorrectliteralvalue.28.Toassignadoublevariabledtoafloatvariablex,youwriteA.x=(long)dB.x=(int)d;C.x=d;D.x=(float)d;29.whatisydisplayedinthefo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

(完整版)面向对象编程基础习题及答案

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部