JavaWord文档下载推荐.docx
- 文档编号:20778367
- 上传时间:2023-01-25
- 格式:DOCX
- 页数:16
- 大小:19.43KB
JavaWord文档下载推荐.docx
《JavaWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《JavaWord文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。
}
0,2;
0,1;
1,2;
A.i=0j=0
B.i=0j=1
C.i=0j=2
D.i=1j=0
E.i=1j=1
F.i=1j=2
G.i=2j=0
H.i=2j=1
I.i=2j=2BCF
3.Whatgetsprintedwhenthefollowingcodeiscompiledandrunwiththefollowingcommand-
javatest2
Selecttheonecorrectanswer.
publicclasstest{
publicstaticvoidmain(Stringargs[]){
IntegerintObj=Integer.valueOf(args[args.length-1]);
inti=intObj.intValue();
if(args.length>
1)
System.out.println(i);
0)
System.out.println(i-1);
else
System.out.println(i-2);
4.
A.test
B.test-1
C.0
D.1
E.2B
5.InJavatechnologywhatexpressioncanbeusedtorepresentnumberofelementsinanarraynamedarr?
arr.length
6.Howwouldthenumber5berepresentedinhexusingup-tofourcharacters.Ox05十六进制中的表示为0X--,八进制为0--
7.WhichofthefollowingisaJavakeyword.Selectthefourcorrectanswers.
A.extern
B.synchronized
C.volatile
D.friend
E.friendly
F.transient
G.this
H.thenBCFG
8.Isthefollowingstatementtrueorfalse.Theconstructorofaclassmustnothaveareturntype.
A.true
B.false
9.WhatisthenumberofbytesusedbyJavaprimitivelong.Selecttheonecorrectanswer.
A.Thenumberofbytesiscompilerdependent.
B.2
C.4
D.8
E.64E
10.Whatisreturnedwhenthemethodsubstring(2,4)isinvokedonthestring"
example"
?
IncludetheanswerinquotesastheresultisoftypeString.am第二个开始持续2个
11.Whichofthefollowingiscorrect?
Selectthetwocorrectanswers.
A.ThenativekeywordindicatesthatthemethodisimplementedinanotherlanguagelikeC/C++.
B.TheonlystatementsthatcanappearbeforeanimportstatementinaJavafilearecomments.
C.Themethoddefinitionsinsideinterfacesarepublicandabstract.Theycannotbeprivateorprotected.
D.Aclassconstructormayhavepublicorprotectedkeywordbeforethem,nothingelse.AD
12.Whatistheresultofevaluatingtheexpression14^23.Selecttheonecorrectanswer.
A.25异或01110跟1011111001
B.37
C.6
D.31
E.17
F.9
G.24A
13.Whichofthefollowingaretrue.Selecttheonecorrectanswers.
A.&
&
operatorisusedforshort-circuitedlogicalAND.
B.~operatoristhebit-wiseXORoperator.
C.|operatorisusedtoperformbitwiseORandalsoshort-circuitedlogicalOR.
D.TheunsignedrightshiftoperatorinJavais>
>
.A
14.Nametheaccessmodifierwhichwhenusedwithamethod,makesitavailabletoalltheclassesinthesamepackageandtoallthesubclassesoftheclass.public
15.Whichofthefollowingistrue.Selectthetwocorrectanswers.
A.Aclassthatisabstractmaynotbeinstantiated.
B.Thefinalkeywordindicatesthatthebodyofamethodistobefoundelsewhere.Thecodeiswritteninnon-Javalanguage,typicallyinC/C++.
C.Astaticvariableindicatesthereisonlyonecopyofthatvariable.
D.Amethoddefinedasprivateindicatesthatitisaccessibletoallotherclassesinthesamepackage.AC
16.Whatallgetsprintedwhenthefollowingprogramiscompiledandrun.Selectthetwocorrectanswers.
inti,j=1;
i=(j>
1)?
2:
1;
i=1
switch(i){
case0:
System.out.println(0);
break;
case1:
System.out.println
(1);
case2:
System.out.println
(2);
case3:
System.out.println(3);
17.
A.0
B.1
C.2
D.3BC
18.Whatallgetsprintedwhenthefollowingprogramiscompiledandrun.Selecttheonecorrectanswer.
inti=0,j=2;
do{
i=++i;
j--;
}while(j>
0);
D.Theprogramdoesnotcompilebecauseofstatement"
i=++i;
"
C
19.Whatallgetsprintedwhenthefollowinggetscompiledandrun.Selectthethreecorrectanswers.
inti=1,j=1;
try{
i++;
if(i/j>
1)
catch(ArithmeticExceptione){
catch(ArrayIndexOutOfBoundsExceptione){
catch(Exceptione){
finally{
System.out.println(4);
D.3
E.4BDE
20.Whatallgetsprintedwhenthefollowinggetscompiledandrun.Selectthetwocorrectanswers.
if(i==j)
21.
E.4DE
22.Whatallgetsprintedwhenthefollowinggetscompiledandrun.Selectthetwocorrectanswers.
Strings1="
abc"
;
Strings2="
if(s1==s2)
else
if(s1.equals(s2))
23.
A.1
C.3
D.4AC
24.Whatallgetsprintedwhenthefollowinggetscompiledandrun.Selectthetwocorrectanswers.
Strings2=newString("
);
25.Whichofthefollowingarelegalarraydeclarations.Selectthethreecorrectanswers.
A.inti[5][];
B.inti[][];
C.int[]i[];
D.inti[5][5];
E.int[][]a;
BCE
26.Whatistherangeofvaluesthatcanbespecifiedforanint.Selecttheonecorrectanswer.
A.Therangeofvaluesiscompilerdependent.
B.-231to231-1
C.-231-1to231
D.-215to215-1
E.-215-1to215B
27.Howcanyouensurethatthememoryallocatedbyanobjectisfreed.Selecttheonecorrectanswer.
A.Byinvokingthefreemethodontheobject.
B.Bycallingsystem.gc()method.
C.Bysettingallreferencestotheobjecttonewvalues(saynull).
D.Garbagecollectioncannotbeforced.TheprogrammercannotforcetheJVMtofreethememoryusedbyanobject.D
28.Whatgetsprintedwhenthefollowingcodeiscompiledandrun.Selecttheonecorrectanswer.
inti=1;
i--;
}while(i>
2);
29.
D.-1A
30.WhichoftheseisalegaldefinitionofamethodnamedmassumingitthrowsIOException,andreturnsvoid.Alsoassumethatthemethoddoesnottakeanyarguments.Selecttheonecorrectanswer.
A.voidm()throwsIOException{}
B.voidm()throwIOException{}
C.voidm(void)throwsIOException{}
D.m()throwsIOException{}
E.voidm(){}throwsIOExceptionA
31.WhichofthefollowingarelegalidentifiernamesinJava.Selectthetwocorrectanswers.
A.%abcd
B.$abcd
C.1abcd
D.package
E._a_long_nameAC
32.Atwhatstageinthefollowingmethoddoestheobjectinitiallyreferencedbysbecomesavailableforgarbagecollection.Selecttheonecorrectanswer.
voidmethodX(){
Stringr=newString("
Strings=newString("
r=r+1;
//1
r=null;
//2
s=s+r;
//3
}//4
A.Beforestatementlabeled1
B.Beforestatementlabeled2
C.Beforestatementlabeled3
D.Beforestatementlabeled4
E.Never.C
33.Strings=newString("
xyz"
Assumingtheabovedeclaration,whichofthefollowingstatementswouldcompile.Selecttheonecorrectanswer.
A.s=2*s;
B.inti=s[0];
C.s=s+s;
D.s=s>
E.Noneoftheabove.C
34.WhichofthefollowingstatementsrelatedtoGarbageCollectionarecorrect.Selectthetwocorrectanswers.
A.Itispossibleforaprogramtofreememoryatagiventime.
B.GarbageCollectionfeatureofJavaensuresthattheprogramneverrunsoutofmemory.
C.ItispossibleforaprogramtomakeanobjectavailableforGarbageCollection.
D.Thefinalizemethodofanobjectisinvokedbeforegarbagecollectionisperformedontheobject.CD
35.Ifabaseclasshasamethoddefinedas
voidmethod(){}
Whichofthefollowingarelegalprototypesinaderivedclassofthisclass.Selectthetwocorrectanswers.
A.voidmethod(){}
B.intmethod(){return0;
}
C.voidmethod(inti){}
D.privatevoidmethod(){}A
36.Inwhichallcasesdoesanexceptiongetsgenerated.Selectthetwocorrectanswers.
inti=0,j=1;
A.if((i==0)||(j/i==1))
B.if((i==0)|(j/i==1))
C.if((i!
=0)&
(j/i==1))
D.if((i!
(j/i==1))D
37.Whichofthefollowingstatementsaretrue.Selectthetwocorrectanswers.
A.ThewaitmethoddefinedintheThreadclass,canbeusedtoconvertathreadfromRunningstatetoWaitingstate.
B.Thewait(),notify(),andnotifyAll()methodsmustbeexecutedinsynchronizedcod
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java
![提示](https://static.bdocx.com/images/bang_tan.gif)