欢迎来到天天文库
浏览记录
ID:58823514
大小:211.00 KB
页数:34页
时间:2020-09-25
《面向对象编程基础习题及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、面向对象编程基础习题及答案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.Toimprover
2、eadabilityandmaintainability,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
3、.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)
4、
5、(x<0)D.(x!=0)
6、
7、(x=0)8.Whichofthefollowingisthecorrectexpressionth
8、atevaluatestotrueifthenumberxisbetween1and100orthenumberisnegative?A.11))
9、
10、(x<0)C.((x<100)&&(x>1))&&(x<0)D.(1>x>100)
11、
12、(x<0)1.Whichofthefollowingisthecorrectexpressionofcharactera?A.'a'B."a"C.' 00a'D.Noneoftheabove.2.Whichofthefollowingstatementprintssmithexam1
13、test.txt?A.System.out.println("smithexam1test.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");3.Supposeiisaninttypevariable.WhichofthefollowingstatementsdisplaythecharacterwhoseUnicodeis
14、storedinvariablei?A.System.out.println(i);B.System.out.println((char)i);C.System.out.println((int)i);D.System.out.println(i+"");4.TheUnicodeof'a'is97.WhatistheUnicodefor'c'?A.96B.97C.98D.995.Whichofthefollowingisaconstant,accordingtoJavanamingconventions?A.MAX_VALUEB.TestC.readD.ReadInt6
15、.Whichofthefollowingassignmentstatementsisillegal?A.floatf=-34;B.intt=23;C.shorts=10;D.floatf=34.0;7.AJavastatementendswitha__________.A.comma(,)B.semicolon(;)C.period(.)D.closingbrace8.TheassignmentoperatorinJavais__________.A.:=B.=C.==D.<-1.Supposemandrareintegers.Whati
此文档下载收益归作者所有