2020年计算机二级JAVA考试每日一练(5月7日)
2020年计算机二级JAVA考试每日一练(5月7日)
1.阅读下列程序片段。
Public void test(){
Try{
sayHello();
system.out.println("hello"):
}catch(ArraylndexOutOfBoundException e){
System.out.println("ArraylndexOutOfBoundExcep—
tion");
}catch(Exception e){
System.out.println("Exception"):
}finally{
System.Out.println("finally");
}
}
如果sayHello()方法正常运行,则test()方法的运行结果将是( )。
A.Hello
B.ArraylndexOutOfBondsException
C.Exception
Finally
D.Hello
Finally
答案:D
2.为使Java程序独立于平台,Java虚拟机把字节码与各个操作系统及硬件( )。
A.分开
B.结合
C.联系
D.融合
答案:A
3.Java中的基本数据类型int在不同的操作系统平台的字长是( )。
A.不同的
B.32位
C.64位
D.16位
答案:B
4.String、StingBuffer都是( )类,都不能被继承。
A.static
B.abstract
C.final
D.Private
答案:C
5.下列程序的功能是统计字符串中“array”的个数,在程序的空白处应填入的正确选项是( )。
public class FindKeyWords(
public static void main(sring[]args){
sting text=
"An array is a data structur that stores a eollection of"
+"values of the same type.You access each individu-
al value"
+"through an integer index.For example.if a is an
array"
+"of inergers,then all]is the ith integer in the ar-
ray.";
Int arrayCount=0;
Int idex=-l;
Sting arrarStr="array":
Index=text.indexof(arrayStr);
While(index 0){
++arrayCount:
Index+=arrayStr.1ength();
Index=text.indexof(arrayStr,index);
}
System.OUt.println
("the text contains"+arrayCount+"arrays");
}
}
A.<
B.=
C.<=
D.>=
答案:D
更多2020年计算机二级JAVA考试每日一练试题,请继续关注环球网校计算机二级频道。需要及时了解考试动态的小伙伴可“ 免费预约短信提醒”届时环球网校会及时为大家推送2020年计算机二级考试相关信息提醒。环球网校友情提示:对于想要参加计算机二级考试的小伙伴们,环球网校特地为您准备了计算机二级考试资料,如有需要请点击文章下方“免费下载>>>计算机二级考试资料”下载学习。