JAVA双语教学考试试A卷及答案docx.docx

上传人:b****7 文档编号:9613764 上传时间:2023-02-05 格式:DOCX 页数:22 大小:73.21KB
下载 相关 举报
JAVA双语教学考试试A卷及答案docx.docx_第1页
第1页 / 共22页
JAVA双语教学考试试A卷及答案docx.docx_第2页
第2页 / 共22页
JAVA双语教学考试试A卷及答案docx.docx_第3页
第3页 / 共22页
JAVA双语教学考试试A卷及答案docx.docx_第4页
第4页 / 共22页
JAVA双语教学考试试A卷及答案docx.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

JAVA双语教学考试试A卷及答案docx.docx

《JAVA双语教学考试试A卷及答案docx.docx》由会员分享,可在线阅读,更多相关《JAVA双语教学考试试A卷及答案docx.docx(22页珍藏版)》请在冰豆网上搜索。

JAVA双语教学考试试A卷及答案docx.docx

JAVA双语教学考试试A卷及答案docx

注意事项:

请将各题答案按编号顺序填写到答题卷上,答在试卷上无效。

-、单项选择题(1~20每小题1分,21*30每小题2分,共40分)

Whichstatementofassigningalongtypevariabletoahexadecimalvalueiscorrect?

A.

0|P

g'曲4.

unI

5.

longnumber=345L;B.longnumber=0345;

C.longnumber=0345L;D.longnumber=0x345L;

Whichlayoutmanagerisusedwhentheframeisresizedthebuttons'spositionintheFramemightbechanged?

A.BorderLayoutB.FlowLayoutC.CardLayoutD.GridLayoutWhicharenotJavaprimitivetypes?

A.shortB.BooleanC.byteD.float

Giventhefollowingcode:

if(x>0){System.out.println("firstn);}

elseif(x>-3){System.out.println(MsecondH);}

else{System.out.println(MthirdH);}

Whichrangeofxvaluewouldprintthestringusecond11?

A.x>0B.x>-3C.x<=-3D.x<=0&x>-3

7.Giventhefollowingcode:

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[]="HelloJava";

C.newStrings="HelloJava”;D.Strings[]=newString("Hello

Java");

23.Ifarr[]containsonlypositiveintegervalues,whatdoesthisfunctiondo?

publicintguessWhat(intarr[]){

intx=0;

for(inti=0;i

x=x

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;}

5.

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

System.out.print(s.charAt(i));

}

A.acegB.bdfC.abcdefg

33-Whatistheresultofexecutingthefollowingcode:

publicclassTest{

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);

else

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

Derived.amethod()

B.Derived.amethod()

100

Derived.amethod()D.Compiletimeerror

publicclassTest{

Stringsl=nmenun;

publicstaticvoidmain(Stringargs[]){intz=2;

Testt=newTest();

System.out.println(t.sl+z);

38.Whatistheresultofexecutingthefollowingcode:

publicclassTestimplementsA{

intx=5;

publicstaticvoidmain(Stringargs[]){

Testcl=newTest();

System.out.println(cl.x+A.k);

}

}

interfaceA{

intk=10;

D.105

}

A.5B.10C.15

39-Whatistheresultofexecutingthefollowingcode:

importjava.util.Arrays;

publicclassTest{

publicstaticvoidmain(String[]unused){

String[]str={"xxx”,”zzz",”yyy”,”aaa"};

Arrays.sort(str);

intindex=Arrays.binarySearch(str,Hzzzn);if(index==-l)

System.out.println(HnoH);

else

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

}

}

System.out.println(',sum=,,4-sum);

A.9B.11C.15

41.Whatistheresultofexecutingt

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 管理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1