JAVA双语教学考试试A卷及答案docxWord文档下载推荐.docx
- 文档编号:22749790
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:22
- 大小:73.21KB
JAVA双语教学考试试A卷及答案docxWord文档下载推荐.docx
《JAVA双语教学考试试A卷及答案docxWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《JAVA双语教学考试试A卷及答案docxWord文档下载推荐.docx(22页珍藏版)》请在冰豆网上搜索。
publicclassPerson{intarr||=newint|10];
publicstaticvoidmain(Stringa|]){
System.out.println(arr|11);
Whichstatementiscorrect?
A.Whencompilationsomeerrorwilloccur.
B・Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.
C.Theoutputiszero.
D.Theoutputisnull.
8.Shortanswer:
Thedecimalvalueofiis13,theoctalivalueis:
A.14B.015C.0x14D.012
9.ApublicmembervairablecalledMAX_LENGTHwhichisinttype,thevalueofthe
variableremainsconstantvalue100.Useashortstatementtodefinethevariable.
A.publicintMAX_LENGTH=100;
B.finalintMAX_LENGTH=100;
C.finalpublicintMAX_LENGTH=100;
D.publicfinalintMAX_LENGTH=100.
10.WhichcorrectlycreateanarrayoffiveemptyStrings?
A.Stringa[]=f"
};
B.Stringa[5];
C.String[5]a;
D.String[]a=newString[5];
for(inti=0;
i<
5;
a[i++]=null);
11.Giventhefollowingmethodbody:
{if(sometest()){
unsafe();
}else{
safe();
}
Themethod"
unsafe”mightthrowanIOException(whichisnotasubclassofRunTimeException).Whichcorrectlycompletesthemethodofdeclarationwhenaddedatlineone?
A.publicvoidmethodName()throwsException
B・publicvoidmethodname()
C.publicvoidmethodName()throwIOException
D.publicIOExceptionmethodName()
12.Whatwouldbetheresultofattemptingtocompileandrunthefollowingpieceofcode?
publicclassTest{staticintx;
publicstaticvoidmain(Stringargs[J){
System.out.println(HValueis11+x);
A.TheoutputnValueis0Hisprinted.
B.AnobjectoftypeNullPointerExceptionisthrown.
C.A"
possiblereferencebeforeassignment11compilererroroccurs.
D.AnobjectoftypeArraylndexOutOfBoundsExceptionisthrown.
13.Whatisthereturn-typeofthemethodsthatimplementtheMouseListenerinterface?
A.booleanB・BooleanC.void
14.SelectvalididentifierofJava:
D.Point
A.#passB.3d_gameC.$charge
15.GivenaTextFieldthatisconstructedlikethis:
TextFieldt=newTextField(30);
Whichstatementistrue?
A.Thedisplayedwidthis30columns.
D.this
B.Thedisplayedstringcanusemultiplefonts.
C.Thedisplayedlinewillshowexactlythirtycharacters.
D.Themaximumnumberofcharactersinalinewillbethirty.
16.WhichdeclaresanabstractmethodinanabstractJavaclass?
A.publicabstractmethod();
B.publicabstractvoidmethod();
C.publicvoidabstractMethod(};
D・publicabstractvoidmethod(){}
17.WhathappenswhenthismethodiscalledwithaninputofnJavarules11?
1.publicStringaddOK(StringS){
2.S+二”OK!
”;
3.returnS;
4.}
Selectonecorrectanswer
A.ThemethodwillreturnuJavarulesOK!
H.
bethrown.
C.Themethodwillreturn"
OK!
nJavarules11.
18.WhichofthefollowingareJavakeywords?
B.Aruntimeexceptionwill
D.Themethodwillreturn
A.arrayB.booleanC.IntegerD.Long
19.Assumethatvalhasbeendefinedasanintforthecodebelow.
if(val>
4){
System.out.println(HTestAn);
}elseif(val>
9){
System.out.println(uTestBn);
elseSystem.out.println(HTestCH);
Whichvaluesofvalwillresultin”TestC”beingprinted:
A.val<
4B.valbetween4and9C.val=10D.val>
9
20.Whichofthefollowingarevaliddefinitionsofanapplication'
smain()method?
A.publicstaticvoidmain();
B.publicstaticvoidmain(Stringargs);
C.publicstaticvoidmain(Stringargs[]);
D.publicstaticvoid
main(Graphicsg);
21.Afterthedeclaration:
char[]c=newchar[100];
whatisthevalueofc[50]?
A.50B.””C.‘\u0032’D.,\u0000,
22.Whichofthefollowingstatementsassigns"
HelloJava”totheStringvariables?
A.Strings="
HelloJava"
;
B.Strings[]="
C.newStrings="
HelloJava”;
D.Strings[]=newString("
Hello
Java"
);
23.Ifarr[]containsonlypositiveintegervalues,whatdoesthisfunctiondo?
publicintguessWhat(intarr[]){
intx=0;
for(inti=0;
arr.length;
i++)
x=x<
arr[i]?
arr[i]:
x;
returnx;
A.Returnstheindexofthehighestelementinthearray
B・Returnstrue/falseifthereareanyelementsthatrepeatinthearray
C.Returnshowmanyevennumbersareinthearray
D.Returnsthehighestelementinthearray
24.Whichofthefollowingarelegaldeclarationsofatwo-dimensionalarrayofintegers?
A.int[5][5]a=newint[][];
B.inta=newint[5,5];
C.inta[J[]=newint[5][5];
D.int[][]a=new[5]int[5];
25.Ifval=1inthecodebelow:
switch(val){
case1:
System.out.print(nPM);
case2:
case3:
System.out.print(nQH);
break;
case4:
System.out.print(nRn);
default:
System.out.print(nSu);
A.PB.PQC.QSD.PQRS
26.Giventhefollowingcode:
1.
publicclassTest{
2.
intm,n;
3.
publicTest(){}
4.
publicTest(inta){m=a;
publicstaticvoidmain(Stringarg[J){
6.
Testtl,t2;
7.
intj,k;
&
j=0;
k=0;
9.
tl=newTest();
10.
t2=newTest(j,k);
11.
12.
Whichlinewouldcauseoneerrorduringcompilation?
A.line3B.line5C.line6D.line10
27.Forthecode:
m=0;
while(++m<
2)
System.out.println(m);
Whichofthefollowingareprintedtostandardoutput?
A.0B.1C.2D.3
28.Considerthefollowingcode:
Whatwillhappenwhenyoutrytocompileit?
publicclassInnerClass{
publicstaticvoidmain(String[Jargs){}
publicclassMylnnerf}
A.Itwillcompilefine.
B・Itwillnotcompile,becauseyoucannothaveapublicinnerclass.
C.Itwillcompilefine,butyoucannotaddanymethods,becausethenitwillfailtocompile.
D.Itwillcompilefail.
29.Whatistheresultofexecutingthefollowingcode:
publicclassTest{
publicstaticvoidmain(Stringargs[]){
Stringword二MrestructureM;
System.out.println(word.substring(2,5));
A.restB.esC.strD.st
30.Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassTest{
publicstaticvoidmain(Stringargsfl){
System.out.println(9A2);
3LWhencallfact(3),Whatistheresult?
intfact(intn){
if(n<
=l)return1;
else
returnn^fact(n-l);
D.0
D.abed
A.2B.6C.3
32.Whatistheresultofexecutingthefollowingcode:
Strings=newString(HabcdefgH);
for(inti=0;
i<
s.length();
i+=2){
System.out.print(s.charAt(i));
A.acegB.bdfC.abcdefg
33-Whatistheresultofexecutingthefollowingcode:
publicstaticvoidchangeStr(Stringstr){str=nwelcomeH;
publicstaticvoidmain(String[]args){Stringst—”12345”;
changeStr(str);
System.out.println(str);
Pleasewritetheoutputresult:
A.welcomeB.12345C.welcomel2345D.12345welcome
34.Whatistheresultofexecutingthefollowingcode:
1.publicclassTest{
2.staticbooleanfoo(charc){
3.System.out.print(c);
4.returntrue;
5.}
6.publicstaticvoidmain(String[]argv){
7.inti=0;
for(foo(A);
foo('
B'
)&
(i<
2);
foo(C)){
9.i++;
10.foo(D);
12.}
13.}
14.}
Whatistheresult?
A.ABDCBDCBB.ABCDABCD
C.Compilationfails.D.Anexceptionisthrownatruntime.
35.Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?
publicfinalclassTest4{
classInner{
voidtest(){
if(Test4.this.flag);
sample();
privatebooleanflag=false;
publicvoidsample(){
System.out.println(HSampleH);
publicTest4(){
(newInner()).test();
publicstaticvoidmain(Stringargs[]){newTest4();
Whatistheresult:
A.Printout"
Sample^
B・Programproducesnooutputbuttermiantescorrectly.
C.Programdoesnotterminate.
D.Theprogramwillnotcompile
36.Whatistheresultofexecutingthefollowingfragmentofcode:
classBase{
Base(){
amethod();
inti=100;
publicvoidamethod(){
System.ou匚println(nBase.amethod()H);
publicclassDerivedextendsBase{
inti=-1;
publicstaticvoidmain(Stringargv[]){Baseb=newDerived();
System.out.println(b.i);
b.amethod();
publicvoidamethod()
System.out.println(HDerived.amethod()n);
A.Derived.amethod()
Derived.amethod()
C.100
B.Derived.amethod()
100
Derived.amethod()D.Compiletimeerror
Stringsl=nmenun;
publicstaticvoidmain(Stringargs[]){intz=2;
Testt=newTest();
System.out.println(t.sl+z);
38.Whatistheresultofexecutingthefollowingcode:
publicclassTestimplementsA{
intx=5;
Testcl=newTest();
System.out.println(cl.x+A.k);
interfaceA{
intk=10;
D.105
A.5B.10C.15
39-Whatistheresultofexecutingthefollowingcode:
importjava.util.Arrays;
publicstaticvoidmain(String[]unused){
String[]str={"
xxx”,”zzz"
”yyy”,”aaa"
};
Arrays.sort(str);
intindex=Arrays.binarySearch(str,Hzzzn);
if(index==-l)
System.out.println(HnoH);
System.out.println(HyesH);
A.noB.xxxC.0D.yes
D.35
D.16
D.3
intb[][]={{2,3,4},{5,6},{7,8}};
intsum=O;
for(inti=O;
ivb」ength;
i++){for(intj=O;
j<
b[i]」ength;
j++){sum+=b[i]U];
System.out.println('
sum=,,4-sum);
A.9B.11C.15
41.Whatistheresultofexecutingt
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 双语 教学 试试 答案 docx