B.4L应该是long类型的写法,
C.1.1是double类型 ,float f=1.1f是正确写法 79.给出如下代码:( ) 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
静态的方法中可以直接调用静态数据成员 80.以下哪个方法用于定义线程的执行体?() A.start() B.init() C.run() D.main() E.synchronized()
解答:run方法是线程的执行体 81.给出下面的代码段:( ) 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); 解答:CD
C是直接给x,y赋值
D是使用this调用本类中其它的构造方法 82.关于运算符>>和>>>描述正确的是 A.>>执行移动 B.>>执行翻转
C.>>执行有符号左移,>>>执行无符号左移 D.>>执行无符号左移,>>>执行有符号左移 解答:C
83. 选择Java语言中的基本数据类型(多选) A.byte B.Integer C.String D.char E.long 答案:ADE
基本数据类型总共有8个:byte,short,int,long,char,boolean,float,double 84.从下列选项中选择正确的Java表达式 A.int k=new String(“aa”) B.String str=String(“bb”) C.char c=74;
D.long j=8888; 解答:BCD
85. Java I/O程序设计中,下列描述正确的是 A. OutputStream用于写操作 B. InputStream用于写操作 C. I/O库不支持对文件可读可写API 解答:A
B.InputStream用于读操作 C.I/O支持对文件的读写 86.下述代码的执行结果是 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. 代码不能被编译 解答:E
方法重写返回值类型与父类的一致
87、Which two demonstrate a \A. public interface Person { }
public class Employee extends Person{ } B. public interface Shape { }
public interface Rectandle extends Shape { } C. public interface Colorable { } public class Shape implements Colorable { }
D. public class Species{ }
public class Animal{private Species species;} E. interface Component{ }
class Container implements Component{ private Component[] children; } 解答:D
“has a”是关联关系,关联分双向关联和单向关联,双向关联是A,B类分别持有对方的引用(有
是对方的属性).
单向关联是一方持另一方的引用.
88. 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; 解答:B
b和ob对应的类之间没有任何关系,要想b=ob成立要么是父子关系,要么是接口实现类的关系
89. 关于Java语言,下列描述正确的是(多选) A. switch 不能够作用在String类型上 B. List, Set, Map都继承自Collection接口 C. Java语言支持goto语句 D. GC是垃圾收集器,程序员不用担心内存管理 解答:AD
B. Map没有继承Collection接口 C.java不支持goto语句 90. 指出下列程序运行的结果 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