设为首页 加入收藏

TOP

2019年3月计算机二级考试Java强化练习题及答案012
2019-03-11 08:12:09 】 浏览:393
Tags:2019年 3月 计算机 二级 考试 Java 强化 习题 答案 012

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


A.public protected final int i;


B.abstract class Fl{…}


C.private double height;


D.double weight()


答案:C


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


class Test{


public s,tatic void main(String args[]){


MyThread t=new MyThread();


t.displayOutput("t has been createD");


t.start();


}


}


Class MyThread extends Thread{


public void displayOutput(String s){


System.out.println(s);


}


public void run(){


displayOutput("t is running.");


}


}


A.t has been created.


B.t has been created. t is running.


C.t is running.


D.编译出错


答案:B


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


public class Test{


public static void main(String args[]){


int d=101;


int b=220:


long a=321;


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


}


}


A.ArraylndexOutOfBoundsException


B.NumberFormatException


C.ArithmeticException


D.EOFExeeption


答案:C


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


public class Test


{


public static void main(String args[])


{


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=true b=false


b=true c=true


B.fl=true b=false


b=true c=false


C.a=true b=true


b=true c=false


D.a=false b=false


b=true c=false


答案:C


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


public class Test{


public static void main(String args[]){


int a,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.5


B.6


C.7


D.101


答案:B


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


A.栈顶


B.栈底


C.栈端


D.栈尾


答案:A


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


public class Test{


public static void main(String args[]){


int i=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


答案:B


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


A.FlowLayout


B.BorderLayout


C.GridLayout


D.UpLayout


答案:B


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


A.字节流


B.字符流


C.对象输出流


D.数据流


答案:C


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


程序代码:


public class throwsExeeption{


static void Proc(intsel)


throws Arithmetic Exception,Array Index Out Of


Bounds Exception{


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


if(sel= =0){


System.OUt.println("noException caught");


return;


}


else if(sel= =l){


int iArray[]=newint[4];


iArray[1]=3;


}


}


public static void main(String args[]){


try{


Proe(O);


Proc(1);


}


catch(Array Index Out Of Bounds Exception e){


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


}


finally{


System.out.println("inProcfinally"):


}


}


}


执行结果:


In Situation 0


no Exception caught


in Proc finally


A.In Situation l


B.In Situation


C.with Catch


D.int iArray l


答案:A


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

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目