34.下列说法错误的有( )
A. 在类方法中可用 this 来调用本类的类方法 B. 在类方法中调用本类的类方法时可直接调用 C. 在类方法中只能调用本类中的类方法 D. 在类方法中绝对不能调用实例方法
35.从下面四段(A,B,C,D)代码中选择出正确的代码段( )
A.abstract class Name { private String name;
public abstract boolean isStupidName(String name) {}
}
B.public class Something { void doSomething () { private String s = \
int l = s.length();
}
}
C.public class Something {
public static void main(String[] args) {
Other o = new Other(); new Something().addOne(o); }
public void addOne(final Other o) {
o.i++;
}
}
class Other {
public int i;
}
D.public class Something { public int addOne(final int x) { return ++x; }
36.选择下面代码的运行结果:( )。
public class Test{
public void method(){
for(int i = 0; i < 3; i++){
System.out.print(i);
}
System.out.print(i); }
} A.0122 B.0123 C.编译错误 D.没有任何输出
}
37.请看如下代码
class Person {
private int a;
public int change(int m){return m;}
}
public class Teacher extends Person{
public int b;
public static void main(String arg[]){
Person p = new Person();
Teacher t = new Teacher(); int i;
// point x }
}
下面哪些放在// point x?行是正确的?( ) A.i = m; B.i = b; C.i = p.a;
D.i = p.change(30); E.i = t.b;
38.下面那几个函数是 public void method(){...}的重载函数?( ) A.public void method( int m){...} B.public int method(){...} C.public void method2(){...}
D.public int method(int m,float f ){...}
39.已知表达式int m[] = {0,1,2,3,4,5,6};下面哪个表达式的值与数组下标量总数相等?( A. m.length() B. m.length
C. m.length()+1 D. m.length+1
40.方法 resume()负责恢复哪些线程的执行( ) A.通过调用 stop()方法而停止的线程。 B.通过调用 sleep()方法而停止的线程。 C.通过调用 wait()方法而停止的线程。 D.通过调用 suspend()方法而停止的线程。
41.有关线程的哪些叙述是对的( )
A 一旦一个线程被创建,它就立即开始运行。
B 使用 start()方法可以使一个线程成为可运行的,但是它不一定立即开始运行。 C 当一个线程因为抢先机制而停止运行,它被放在可运行队列的前面。 D 一个线程可能因为不同的原因停止并进入就绪状态。
) 42.已知如下代码:( )
public class Test{
public static void main(String arg[]){ int i = 5;
do{ System.out.print(i);
}while(--i>5);
System.out.print(“finished”); }
}
执行后的输出是什么? A 5 B 4 C 6
D finished
43.给出如下代码:( )
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
44.给出下面的代码段:( )
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);
)
45.关于运算符>>和>>>描述正确的是( ) A.>>执行移动 B.>>执行翻转
C.>>执行有符号左移,>>>执行无符号左移 D.>>执行无符号左移,>>>执行有符号左移
46.下述代码的执行结果是
class Super {
public int getLength() {return 4;}
}
public class Sub extends Super {
public long getLength() {return 5;}
public static void main (String[]args){ Super sooper = new Super (); Super sub = new Sub();
System.out.printIn(sooper.getLength()+ “,” + sub.getLength()); } } A. 4 4 B. 4 5 C. 5 4 D. 5 5
E. 代码不能被编译
47.Given the folowing classes which of the following will compile without error?( ) interface IFace{}
class CFace implements IFace{}
class Base{}
public class ObRef extends Base{
public static void main(String argv[]){
ObRef ob = new ObRef(); Base b = new Base();
Object o1 = new Object();
IFace o2 = new CFace(); }
}
A. o1=o2; B. b=ob; C. ob=b; D. o1=b;
48. 关于 Java 语言,下列描述正确的是( )
A. switch 不能够作用在 String 类型上
B. List, Set, Map 都继承自 Collection 接口
C. Java 语言支持 goto 语句
D. GC 是垃圾收集器,程序员不用担心内存管理
49.指出下列程序运行的结果( )
public class Example{
String str=new String(\char[]ch={'a','b','c'};
public static void main(String args[]){
Example ex=new Example(); ex.change(ex.str,ex.ch);
System.out.print(ex.str+\System.out.print(ex.ch);
}
public void change(String str,char ch[]){
str=\ch[0]='g'; } }
A.good and abc B.good and gbc C.test ok and abc D.test ok and gbc
50.下列描述中,哪些符合 Java 语言的特征( )
A. 支持跨平台(Windows,Linux,Unix 等) B. GC(自动垃圾回收),提高了代码安全性 C. 支持类 C 的指针运算操作
D. 不支持与其它语言书写的程序进行通讯
51、关于异常(Exception),下列描述正确的是( )
A. 异常的基类为 Exception,所有异常都必须直接或者间接继承它
B. 异常可以用 try{ . . .}catch(Exception e){ . . .}来捕获并进行处理
C. 如果某异常继承 RuntimeException,则该异常可以不被声明 D. 异常可以随便处理,而不是抛给外层的程序进行处理