2020年计算机二级JAVA考试每日一练(4月27日)
2020年计算机二级JAVA考试每日一练(4月27日)
1.下列方法中,不属于Throwable类的方法是( )。
A.printMessage
B.getMessage
C.toString
D.fillStackTrace
答案:C
2.下列程序的输出结果是( )。
Public class Test{
Public static void main(String[]args){
int[]array=(2,4,6,8,10);
int size=6;
int result=-l:
try{
for(int i=0;i
if(array[i]= =20)result=i:
}
catch(ArithmeticException e){
System.out.println("Catch---1");
}
catch(ArraylndexOutOfBoundsException e){
System.out.println("Catch---2"):
}
catch(Exception e){
System.out.println("Catch---3"):
}
}
A.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对
答案:B
3.下列包中,包含JOptionPane类的是( )。
A.javax.swing
B.java.lang
C.java.util
D.java.Applet
答案:A
4.下列选项中,与成员变量共同构成一个类的是( )。
A.关键字
B.方法
C.运算符
D.表达式
答案:B
5.下列程序的功能是将一个整数数组写入二进制文件,在程序的下画线处应填入的选项是( )。
importjava.io.*;
public class XieShuzu{
Dublic static void main(String[]a){
Int[]myArray=(10,20,30,40);
try{
DataOutputStream dos=
new DataOutputStream(new
FileOutput Stream("ints.dat"));
for(int i=0:i
dos. (myArray[i]);
dos.close();
System.out.println("已经将整数数组写入二进制文件:ints.dat");
}catch(IOException ioe)
{System.out.println("IO Excepr_on");}
}
}
A.writeArray
B.writeByte
C.writeInt
D.writeDouble
答案:C
更多2020年计算机二级JAVA考试每日一练试题,请继续关注环球网校计算机二级频道。需要及时了解考试动态的小伙伴可“ 免费预约短信提醒”届时环球网校会及时为大家推送2020年计算机二级考试相关信息提醒。环球网校友情提示:对于想要参加计算机二级考试的小伙伴们,环球网校特地为您准备了计算机二级考试资料,如有需要请点击文章下方“免费下载>>>计算机二级考试资料”下载学习。