JAVA基础考试题
(请勿在此卷上填写答案,请将答案写在答题卡上,考试时间90分钟,总分102分)一、选择题(每题2分,共42分;错选不给分;少选给1分)
1
====
1. public class test {
2. public static void main (String args[]) {
3. int i = 5;
4. int j = i<<2;
5.
6. }
7. }
What is the decimal value of j at line 5?
A. 0
B. 1
C. 20
D. -15
E. An error at line 3 causes compilation to fail.
F. An error at line 4 causes compilation to fail.
2
====
Integer i = new Integer (42);
Long l = new Long (42);
Double d = new Double (42.0);
Which expressions evaluate to True?
A. (i == l)
B. (i == d)
C. (d == l)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))
G. None
3
====
1. public class test {
2. private static int j = 0;
3.
4. private static boolean methodB(int k) {
5. j += k;
6. return true;
7. }
8.
9. public static void methodA(int i) {
10. boolean b:
11. b = i < 10 | methodB (4);
12. b = i < 10 || methodB (8);
13. }
14.
15. public static void main (String args[]) {
16. methodA(0);
17. System.out.println(j);
18. }