私立华联学院试题 200一一200学年度第_学期(卷) 课程名称JAVA语言程序设计课程代码任课教师尹蓝系(部)主任签字 学号考生姓名」 系别计算机科学与技术班级」 题号一三三四五六七八九十总分 得分 一、选择题(本题共20小题,每题2分,共40分) 1.欲构造ArrayList类的一个实例,此类继承了Lit接口,下列哪个方法是正 确的() A.ArrayList myList=new Object();B.List myList=new ArrayList (): C.ArrayList myList=new List();D.ListmyList=new List(); 2.paint0方法使用哪种类型的参数() A、Graphics B、Graphics2DC、String D、Color 3.指出正确的表达式() A、byte=l28;B、Boolean=nul;C、long I=0 xfffL;D、 double=0.9239d; 4.指出下列程序运行的结果() public class Example( String str=new String("good"); charDch=('a','b','c'); public static void main(String args[){ 1/14
1 / 14 私 立 华 联 学 院 试 题 200__——200_ _学年度 第__ __学期( 卷) 课程名称 JAVA 语言程序设计课程代码 任课教师尹 菡系(部)主任签字 学号 考生姓名 系别计算机科学与技术 班级 ------------------------------------------------------------------------------------------------------- 题号 一 二 三 四 五 六 七 八 九 十 总 分 得分 一、选择题(本题共 20 小题,每题 2 分,共 40 分) 1.欲构造 ArrayList 类的一个实例,此类继承了 List 接口,下列哪个方法是正 确的 ( ) A、 ArrayList myList=new Object(); B、 List myList=new ArrayList (); C、 ArrayList myList=new List(); D、 List myList=new List(); 2.paint()方法使用哪种类型的参数 ( ) A、 Graphics B、 Graphics2D C、 String D、 Color 3.指出正确的表达式 ( ) A 、 byte=128; B 、 Boolean=null; C 、 long l=0xfffL; D 、 double=0.9239d; 4.指出下列程序运行的结果 ( ) public class Example{ String str=new String("good"); 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+"and ") Sytem.out.print(ex.ch); } public void change(String str,char ch[){ str="test ok"; ch[o]='g'; } A、good and abc B、good and gbc C、testok and abc D、 test ok and gbc 5.运行下列程序,会产生什么结果() public class X extends Thread implements Runablef public void run(( System.out.println("this is run("); public static void main(String args[]) { Thread t=new Thread(new X() t.start(; } 2114
2 / 14 Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.print(ex.str+" and "); Sytem.out.print(ex.ch); } public void change(String str,char ch[]){ str="test ok"; ch[0]='g'; } } A、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5.运行下列程序, 会产生什么结果 ( ) public class X extends Thread implements Runable{ public void run(){ System.out.println("this is run()"); } public static void main(String args[]) { Thread t=new Thread(new X()); t.start(); }
} A、第一行会产生编译错误B、第六行会产生编译错误 C、第六行会产生运行错误D、程序会运行和启动 6.要从文件”fle.dat"文件中读出第10个字节到变量C中,下列哪个方法适 合?() A.FileInputStream in=new FileInputStream("file.dat");in.skip(9) int c=in.read(); B.FileInputStream in=new FileInputStream("file.dat");in.skip(10); int c=in.read(); C.FileInputStream in=new FileInputStream("file dat");int c=in.readO; D、 RandomAccessFile in=new RandomAccessFile("file.dat"); in.skip(9);int c=in.readByte(); 7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小 的变化而改变?() A、CardLayout B、FlowLayout C、BorderLayout D、 GridLayout 8.给出下面代码: public class Personf static int arr]=new int[10]; public static void main(String a[]) 3114
3 / 14 } A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 6.要从文件" file.dat"文件中读出第 10 个字节到变量 C 中,下列哪个方法适 合? ( ) A、 FileInputStream in=new FileInputStream("file.dat"); in.skip(9); int c=in.read(); B、 FileInputStream in=new FileInputStream("file.dat"); in.skip(10); int c=in.read(); C 、 FileInputStream in=new FileInputStream("file . dat"); int c=in.read(); D 、 RandomAccessFile in=new RandomAccessFile("file . dat"); in.skip(9); int c=in.readByte(); 7.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小 的变化而改变? ( ) A、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8.给出下面代码: public class Person{ static int arr[] = new int[10]; public static void main(String a[]) {
System.out.println(arr[1]); 那个语句是正确的?( A、编译时将产生错误;B、编译时正确,运行时将产生错误; C、输出零: D、输出空. 9.下列那个是反斜杠的正确表示?( ANB.NC、D、y 10.下列哪些语句关于内存回收的说明是正确的?() A、程序员必须创建一个线程来释放内存 B、内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出错:() 1)public void modify(){ 2)int I,j.k; 3)1=100: 4)while (I>0){ 5)j=I*2: 6)System.out.println("The value ofj is"+j); 7)k=k+1; 8)1 4114
4 / 14 System.out.println(arr[1]); } } 那个语句是正确的? ( ) A、 编译时将产生错误; B、 编译时正确,运行时将产生错误; C 、输出零; D、 输出空。 9.下列那个是反斜杠的正确表示?( ) A、 \\ B、 *\\ C、 \’ D、 \’\’ 10.下列哪些语句关于内存回收的说明是正确的? ( ) A、 程序员必须创建一个线程来释放内存; B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出错: ( ) 1) public void modify() { 2) int I, j, k; 3) I = 100; 4) while ( I > 0 ) { 5) j = I * 2; 6) System.out.println (" The value of j is " + j ); 7) k = k + 1; 8) I--;
9)) 10} A.line4B、line6C、line7D、line8 12.MAX_LENGTH是int型public成员变量,变量值保持为常量100,用简 短语句定义这个变量。() A.public int MAX_LENGTH=100; B.final int MAX_LENGTH=100; C.final public int MAX_LENGTH=100; D.public final int MAX_LENGTH=100 13.给出下面代码: 1)class Parent{ 2)private String name; 3)public Parent(0 4)} 5)public class Child extends Parent{ 6)private String department; 7}public Child()) 8)public String getValue(){return name; 9)public static void main(String arg[){ 10)Parent p=new Parent(); 11) 12}) 5/14
5 / 14 9) } 10} } A、 line 4 B、 line 6 C、 line 7 D、 line 8 12.MAX_LENGTH 是 int 型 public 成员变量, 变量值保持为常量 100,用简 短语句定义这个变量。 ( ) A、 public int MAX_LENGTH=100; B、 final int MAX_LENGTH=100; C、 final public int MAX_LENGTH=100; D、 public final int MAX_LENGTH=100. 13.给出下面代码: 1) class Parent { 2} private String name; 3} public Parent(){} 4} } 5) public class Child extends Parent { 6} private String department; 7} public Child() {} 8} public String getValue(){ return name; } 9} public static void main(String arg[]) { 10} Parent p = new Parent(); 11} } 12} }