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