设为首页 加入收藏

TOP

2018年9月计算机二级Java考试强化训练题(3)
2018-04-16 10:09:28 】 浏览:329
Tags:2018年 9月 计算机 二级 Java 考试 强化 训练

1.下列选项成员变量声明正确的是()。


A.publicprotectedfinalinti;


B.abstractclassFl{…}


C.privatedoubleheight;


D.doubleweight()


2.下面程序段的输出结果是()。


classTest{


publics,taticvoidmain(Stringargs[]){


MyThreadt=newMyThread();


t.displayOutput("thasbeencreateD");


t.start();


}


}


ClassMyThreadextendsThread{


publicvoiddisplayOutput(Strings){


System.out.println(s);


}


publicvoidrun(){


displayOutput("tisrunning.");


}


}


A.thasbeencreated.


B.thasbeencreated.tisrunning.


C.tisrunning.


D.编译出错


3.执行下列程序时,会产生什么异常()。


publicclassTest{


publicstaticvoidmain(Stringargs[]){


intd=101;


intb=220:


longa=321;


System.OUt.println((a-b)/(a-b-d));


}


}


A.ArraylndexOutOfBoundsException


B.NumberFormatException


C.ArithmeticException


D.EOFExeeption


4.下面程序段的输出结果为()。


publicclassTest


{


publicstaticvoidmain(Stringargs[])


{


booleana,b,C;


a=(3<5):


b=(a==true);


System.out.println("a="+a+"b="+b);


c=(b==false);


System.out.println("b="+b+"c="+c);


}


}


A.a=trueb=falseB.fl=trueb=false


b=truec=trueb=truec=false


C.a=trueb=trueD.a=falseb=false


b=truec=falseb=truec=false


5.下面程序段的输出结果是()。


publicclassTest{


publicstaticvoidmain(Stringargs[]){


inta,b;


for(a=1,b=1;a<=100;a++){


if(b>=10)break;


if(b%2==1){


b+=2:


continue;


}


}


System.OUt.println(a);


}


}


A.5B.6


C.7D.101


6.栈中允许进行插入和删除的一端称为()。


A.栈顶B.栈底


C.栈端D.栈尾


7.下面程序段的输出结果是()。


publicclassTest{


publicstaticvoidmain(Stringargs[]){


inti=1:


switch(i){


case0:


System.OUt.println("0");


break;


casel:


System.out.println("1");


case2:


System.OUt.println("2");


break;


default:


System.out.println("default");


}


}


}


A.01


B.12


C.10


D.21


8.Frame默认的布局管理器是()。


A.FlowLayout


B.BorderLayout


C.GridLayout


D.UpLayout


9.在Java语言中,ObjectOutputStream是指()。


A.字节流


B.字符流


C.对象输出流


D.数据流


10.请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是()。


程序代码:


publicclassthrowsExeeption{


staticvoidProc(intsel)


throwsArithmeticException,ArrayIndexOutOf


BoundsException{


System.out.println("InSituation"+sel);


if(sel==0){


System.OUt.println("noExceptioncaught");


return;


}


elseif(sel==l){


intiArray[]=newint[4];


iArray[1]=3;


}


}


publicstaticvoidmain(Stringargs[]){


try{


Proe(O);


Proc(1);


}


catch(ArrayIndexOutOfBoundsExceptione){


System.out.println("Catch"+e);


}


finally{


System.out.println("inProcfinally"):


}


}


}


执行结果:


InSituation0


noExceptioncaught


inProcfinally


A.InSituationl


B.InSituation


C.withCatch


D.intiArrayl


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇2018年9月计算机二级Java考试强化.. 下一篇2018年9月计算机二级Java考试强化..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目