正确答案:A
解析:
4.
(单选题)对于下列程序:
public class Test {
public static void main(String[] a){
int a = 3, b = 4, c = 5;
boolean d = a > b && c++ > 4;
System.out.println(c + “,” + d);
}
} 的运行结果是:
A.5,true
B.5,false
C.6,true
D.6,false
E.编译错误
正确答案:E
解析:
5.
(单选题)对于代码:
public class Test {
public static void main(String[] args){
int i = 5;
// 10 (i=6) + 3 * 7 +
int j = 2*i++ +3*++i;
System.out.println(j);
}
} 的运行结果是:
A.31
B.32
C.33
D.34
E.35
正确答案:A
解析:
6.
(单选题)对于代码:
public class Test {
public static void main(String[] args){
int i = 3;
if(i < 3);
System.out.println(“haha”);
System.out.println(“hehe”);
}
} 的输出结果是:
A.haha
B.hehe
C.haha hehe
D.hehe haha
E.编译时报错
正确答案:C
解析:
7.
(单选题)对于代码:
public class Super {
public static void ma(){
System.out.println(“Super ma”);
}
public void mb(){
System.out.println(“Super mb”);
}
public static void main(String[] args){
Super s = new Sub();
s.ma();
s.mb();
}
}
class Sub extends Super {
public static void ma(){
System.out.println(“Sub ma”);
}
public void mb(){
System.out.println(“Sub mb”);
}
} 的输出结果是:
A.Super ma Super mb
B.Super ma Sub mb
C.Sub ma Super mb
D.Sub ma Sub mb
E.编译出错
正确答案:B
解析:
8.
(单选题)对于代码:
public class Test {
public static void main(String [] args){
MyClass mc = new MyClass();
change(mc);
System.out.println(mc.i);
}
public static void change(MyClass mc){
mc.i = 5;
mc = new MyClass();
mc.i = 8;
}
}
class MyClass{
int i = 3;
} 的运行结果是:
A.0
B.3
C.5
D.8
E.编译错误
正确答案:C
解析:
9.
(单选题)对于代码:
public class Test {
public static void main(String[] args){
int i = 5;
final int j = 10;
add(i);
plus(j);
}
public static void add(final int i){
System.out.println(2 * i);
//i = i * 2 ;
//System.out.println(i);
}
public static void plus(int i){
i *= 2;
System.out.println(i);
}
} 的结果是:
A.10 10
B.10 20
C.5 10
D.5 20
E.编译错误
正确答案:B
解析:
10.
(单选题)对于下列代码:
public class Test {
public static void main(String [] args){
System.out.println(add(3,5));
}
static double add(int i,double j){
return i + j;
}
static double add(double i, int j){
return i + j;
}
static double add(double i ,double j){
return i + j;
}
static double add(float i ,int j){ return i + j;
}
} 的输出结果是:
A.8
B.8.0
C.‘8’
D.‘8.0’
E.编译错误
正确答案:BCE
解析:
23.
(多选题)下列各项可以正确赋值的是:
A.int i = ‘a’;
B.float f = -2;
C.byte b = 128;
D.double d = 100d;
E.char c = 97;
正确答案:ABDE
解析:
24.
(多选题)对于下列各项能够正确编译的是:
A.byte b = 5; b = b + 1;
B.byte a = 3,b = 5; byte c = a + b;
C.byte b = 127; b ++;
D.byte b = 127; b += 3;
E.byte b = 5; b += ‘a’;
正确答案:BE
解析:
28.
(多选题)对于代码:
public class Test {
public int m(int i, int j){
return i + j;
}
} 下列各项中是m()的重载的是:
A.public int m(int j, int i){ return i + j; }
B.public int m(int i, int j){ return i + j + 3; }
C.public void m(double i, double j){ return i + j; }
D.public double m(double i ,int j){ return i + j; }
E.public int m(int i){ return 2 * i; }
正确答案:ABCE
解析:
30.
(多选题)在下列代码的//insert code here 处,加上下列哪行代码运行时会抛出java.lang.ClassCastException?
interface foo{}
class Alpha implements foo{}
class Beta extends Alpha{}
pulic class Delta extends Beta{
public static void main(String[] args){
Beta x = new Beta();
//insert code here
}
}
A.Alpha a = x;
B.foo f = (Delta) x;
C.foo f = (Alpha) x ;
D.Beta b = (Beta)(Alpha)x;
E.Delta d = (Delta)(Alpha)x
正确答案:ABC
解析:
32.
(多选题)对于字符串String s = “2016-11-11 00:11:11”,下列能够将其正确转化为日期对象2016年11月11日0时11分11秒的选项是:
A.Date d = new Date(s);
B.Date date = new SimpleDateFormat(“yyyy/mm/dd hh:MM:ss”).parse();
C.Date date = new SimpleDateFormat(“yyyy-mm-dd hh:MM:ss”).parse();
D.Date date = new SimpleDateFormat(“YYYY-mm-dd hh:MM:ss”).parse();
E.Date date = new SimpleDateFormat(“yyyy-mm-dd HH:MM:ss”).parse();
正确答案:AB
解析:
34.
(多选题)下列各项中说法正确的是:
A.ArrayList是线程不安全的
B.LinkedList是线程不安全的
C.Vector是线程不安全的
D.对于语句Vector<int> v = new Vector();是正确的声明方法
E.对于语句List list = new ArrayList<String>();是正确的声明方法
正确答案:ABE
解析:
35.
(多选题)下列各项挣够正确编译运行的是:
A.Integer i = new Integer(“3”);
B.Float f = 3.5;
C.Integet i = new Integer(“0x45”);
D.Boolean b = new Boolean(null);
E.Boolean b = new Boolean(“aaa”);