一知半解的人,多不謙虛;見多識廣有本領的人,一定謙虛。以下是小編爲大家搜索整理的計算機考試java模擬試題,希望能給大家帶來幫助!更多精彩內容請及時關注我們應屆畢業生考試網!
一、 選擇題
1、下面哪些是java語言中的關鍵字?
A sizeof
B abstract
C NULL
D Native
答:B
2、下面語句哪個是正確的?
A char='abc';
B long l=oxfff;
C float f=0.23;
D double=0.7E-3;
答:D
3、以下程序測試String 類的各種構造方法,試選出其運行效果。
class STR{
public static void main(String args[]){
String s1=new String();
String s2=new String("String 2");
char chars[]={'a',' ','s','t','r','i','n','g'};
String s3=new String(chars);
String s4=new String(chars,2,6);
byte bytes[]={0,1,2,3,4,5,6,7,8,9};
StringBuffer sb=new StringBuffer(s3);
String s5=new String(sb);
tln("The String No.1 is "+s1);
tln("The String No.2 is "+s2);
tln("The String No.3 is "+s3);
tln("The String No.4 is "+s4);
tln("The String No.5 is "+s5);
}
}
A The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is string
The String No.5 is a string
B The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is tring
The String No.5 is a string
C The String No.1 is
The String No.2 is String 2
The String No.3 is a string
The String No.4 is strin
The String No.5 is a string
D 以上都不對
答:A
4、下面語句段的輸出結果是什麼?
int i = 9;
switch (i) {
default:
tln("default");
case 0:
tln("zero");
break;
case 1:
tln("one");
case 2:
tln("two"); }
A default
B default, zero
C error default clause not defined
D no output displayed
答:B
二、不定項選擇題(在每小題的五個備選答案中選出正確答案,並將正確答案的序號填入題幹後面的括號內,錯選多選,漏選均不得分。)
1、給出如下代碼:
class Test{
private int m;
public static void fun() {
// some code...
}
}
如何使成員變量m 被函數fun()直接訪問?
A、將private int m 改爲protected int m
B、將private int m 改爲 public int m
C、將private int m 改爲 static int m
D、將private int m 改爲 int m
答: C
2、下面哪幾個函數是public void example(){...}的重載函數?
A、 public void example( int m){...}
B、public int example(){...}
C、public void example2(){...}
D、 public int example ( int m, float f){...}
答: A,D
3、給出下面的代碼段:
public class Base{
int w, x, y ,z;
public Base(int a,int b)
{
x=a; y=b;
}
public Base(int a, int b, int c, int d)
{
// assignment x=a, y=b
w=d;
z=c;
}
}
在代碼說明// assignment x=a, y=b處寫入如下哪幾個代碼是正確的?
A、 Base(a,b);
B、x=a, y=b;
C、x=a; y=b;D、this(a,b);
答: C,D
4、已知如下定義:String s = "story";
下面哪個表達式是合法的?
A、 s += "books";
B、char c = s[1];
C、int len = th;
D、String t = werCase();
答: A,D
5、Java中main()函數的值是什麼?
A、 String
B、int
C、char
D、void
答
6、如下哪些字串是Java中的標識符?
A、 fieldname
B、super
C、3number
D、#number
E、$number
答: A,E
7、如下哪些是Java中有效的關鍵字?
A、 const
B、NULL
C、false
D、this
E、 native
答:A,C,D,E
8、如下哪些是Java中正確的整數表示?
A、22
B、0x22
C、022
D、22H
答: A,B,C
9、下面的代碼段中,執行之後i 和j 的值是什麼?
int i = 1;
int j;
j = i++;
A、 1, 1
B、1, 2
C、2, 1
D、2, 2
答: C
10、下面句話是正確的?
A、 >> 是算術右移操作符.
B、>> 是邏輯右移操作符.
C、>>> 是算術右移操作符
D、>>> 是邏輯右移操作符
答:A,D
11、下面哪個賦值語句是合法的?
A、float a = 2.0
B、double b = 2.0
C、int c = 2
D、long d = 2
答:B,C,D
12、下面哪個是main()函數的合法參數?
A、char args[]
B、char args[][]
C、String arg要[]
D、String args
答: C
13、下面哪個語句是創建數組的正確語句?
A、 float f[][] = new float[6][6];
B、float []f[] = new float[6][6];
C、float f[][] = new float[][6];
D、float [][]f = new float[6][6];
E、float [][]f = new float[6][];
答:A,B,C,D
14、已知表達式int m[] = {0, 1, 2, 3, 4, 5, 6 };
下面哪個表達式的值與數組下標量總數相等?
A、 th()
B、th
C、th()+1
D、th+1
答:B
15、已知如下的命令執行 java MyTest a b c
請問哪個語句是正確的?
A、 args[0] = "MyTest a b c"
B、args[0] = "MyTest"
C、args[0] = "a"
D、args[1]= 'b'
答:C, D
16、已知如下代碼:
public class Test
{
long a[] = new long[10];
public static void main ( String arg[] ) {
tln ( a[6] );
}
}
請問哪個語句是正確的?
A、Output is null.
B、Output is 0.
C、When compile, some error will occur.
D、When running, some error will occur.
答:B
17、已知如下代碼:
boolean m = true;
if ( m == false )
tln("False");
else
tln("True");
執行結果是什麼?
A、False
B、True
C、None