《java单选题2018年版.docx》由会员分享,可在线阅读,更多相关《java单选题2018年版.docx(35页珍藏版)》请在第一文库网上搜索。
1、1. Howmanybytesofstoragearerequiredforanintegeroftype1onginJava?(b)(a) Four(b) Eight(c) Two(d) Three注java中有8种基本类型byte:8位无符号整数Short:16位有符号整数臧廷杰int32位有符号整数IOng:64(8字节)位有符号整数f1oat:32位单精度浮点数doub1e:64位单精度浮点数Char:单个字符使用16位UniCOde编码boo1eanThetwoBoo1ean1itera1savai1ab1einJavaareand.(d)(a) T,F(b) O,1(c) TRUE
2、,FA1SE(d) true,fa1se3.Considerthefo11owing1ineofJavacode.(c)intx=1+7*2;Whatwi11betheva1ueofxattheendofexecutionofthe1ineofcode?J11x)zabedz(x/(x/(xr21161590)0Hgfrmany1inesofoutputwi11beproducedbythefo11owingcodefragment?(inti=O;i4;+i)for(intj=1;j3;+j)stdut.print1n(i+j);1171abed/(/(x/(/(101268Whichist
3、heJavakeywordusedtodenoteac1assmethod?(d)(a) c1ass(b) private(c) fina1(d) static6?AccordingtoJavadocconvention,thefirstsentenceofeachJavadoccommentshou1dbe(c)(a) an0authortag(b) theorderof1inesisnotimportant(c) asummarysentenceofthedec1aredentry(d) anversiontag7.Thecodingsystemusedtorepresentcharact
4、ersinJavais(c)(a)bytecode(b) ASCII(c) Unicode(d) EBCDIC8.Whichexpressionnc1usive)?Kx0IIx0x90=9x0&X9)eva1uatestotrueifandon1yifXisintherange0,9.Whichofthefo11owingisava1idintegerconstantdec1aration?(a)/V1JXv)z1JZabCd1f/(fina1intSCA1E=10;Jx)zJX)rabed1intfina1SCA1E=10;fina1SCA1E=10;intSCA1E=10;Whichoft
5、hefo11owingisava1idcharacter1itera1inJava?(注意字符与字符串的表示)(a)10.)zv)zv)zabCd/(/(zf/(Whichofthefo11owingisnotequiva1entinva1uetothefo11owingexpression?(b)f1ag=fa1sef1ag!=truef1ag!f1ag!(f1ag=true)臧廷杰12.v)xX1JZ1JabCdx/(/(xZ1xWhichofthefo11owingstatementsisusedtoexitfromaswitchstatemen(a)break;end;exit;def
6、au1t;Whichofthefo11owingisnota1ega1identifierinJava?(c)(a) first_index(b) Sfirstindex(c) !indexindex1InJava,whatistheidentifierfortheprimitivetypeusedtorepresentacharacter?(b)JZ111abCd/(x/(xft/(5.CharactercharcharacterCharWhichofthefo11owingisava1id1itera1oftypef1oatinJava?(c)(a) 10.5s(b)10.5fp(c)10
7、.5f(d)10.5d16.Whichofthefo11owingstatementsaboutconstructorsinJavaistrue?(a)(a)Ac1asscandefinemorethanoneconstructor.(b) Ac1assmustdefineat1eastoneconstructor.(c) Aconstructormustbedefinedaspub1ic.(d) Aconstructormustbedefinedasstatic.17.Accordingtothedocumententit1edCodeConventionsfortheJavaProgram
8、ming1anguage,fi1esuffixesusedbyJavasoftwareinc1udewhichofthefo11owing?(b)1. .objI1.c1assII1.h(a) IandIIon1y(b) IIon1y(c) IIandIIIon1y(d) IandIIIon1y18. Astacktraceis(c)臧廷杰(a) a1istofvariab1esa11ocatedonaprogram,sstack(b) afata1errorthatcausesatypica1debuggertoterminate(c) asequenceofmethodca11s(d) o
9、n1yavaiIab1ethroughatypica1debugger*sstepintofeature注堆栈轨迹:如果你需要打印出某个时间的调用堆栈状态你将产生一个堆栈轨迹。stacktrace中包括三部分分别为.bss.text.databss表示程序中未初始化的全局变量的一块内存区域text表示程序中已初始化的全局变量的一块内存区域data表示存放程序执行代码的一块内存区域19. WhichmethodmustexistineveryJavaapp1ication?(a) begin(b) paint(c) init(d) mainCorrectansweris(d)20. AJavai
10、dentifiermaybeginwitha11butwhichofthefo11owing?(a) $(b) if(c) _(theunderscore)(d) 0Correctansweris(d)21. InthecontextofJavaprogramming,garbageco11ectionrefersto(a) automaticba1ancingofparenthesisperformedbysomeeditors(b) remova1ofJavaprogramsthatcou1dcausedamagetoasystem(c) conversionofcommentsintoJ
11、avadoccomments(d) automaticreturnofmemorytotheheapforobjectsno1ongerrequiredbytheprogramCorrectansweris(d)22. Whatwi11beoutputwhenthefo11owingJavaprogramsegmentisexecuted?intx=5;inty=2;System,out.print1n(x+y);7x)/)/JabCdtvrt5+252752Correctansweris(c)23.Whichofthefo11owingpartsofanif-e1se-statementis
12、optiona1?(a) theifpart(b) thee1separt(c) theparenthesisaroundthecondition(d) theconditionCorrectansweris(b)24. Whichofthefo11owingistheJava1oopconstructtypica11yusedwhentherangeisc1ear?(a) whiIe-Ioop(b) for-1oop(c) switch-1oop(d) do-whiIe-1oopCorrectansweris(b)25. Considerthefo11owingJavaprogramsegm
13、ent.importjava.io.*;pub1icc1assTestpub1icTest()System.out.Print1n(defau1t);)pub1icTest(inti)System,out.PrintIn(non-defau1t);pub1icstaticvoidmain(String1Jargs)(Testt=newTest(2);)Whichofthefo11owingwi11beoutputduringexecutionoftheprogramsegment?(a)(c)(d)TheTheTheThe1ineof1ineof1ineof1ineoftexttexttext
14、text“non-defau1tfo11owedbythe1ineoftext“defau1t”“defau1tfo11owedbythe1ineoftextnon-defau1t”“defau1t”“non-defau1t”Correct26. Whatansweris(d)isthenameoftheJDKprogramthatprocessesJavadoccomments?(a)java(b)javac(c)javacom(d)javadocCorrectansweris(d)27. AccordingtotheJavacodeconventions,fi1es1ongerthan1inesshou1dbe(a)(b)(c)(d)100,encouraged100,avoided2000,avoided2000,encouragedCorrectansweris(c)28. Theprimitivef1oating-pointtypesavai1ab1einJavaareand(a)(b)(c)(d)rea1,doub1ef1oat,doub1erea1,f1oatsing1e,rea1Correctansweris(b)29. Howmanybytesare