(程序设计基础JAVA)期末考试试卷
《程序设计基础(java)》 试题B卷
题号一二三四五六七八九总分得分
试卷说明:闭卷考试,时间120分钟。
一、 填空(本题共15空,每空2分,共30分)
1.。.Java中所有类都是类 的子类。.请填出在java.lang包中与下列基本数据类型相对应的封装类: float:java.lang.Float, char: , boolean: 。 .
6....
1.欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ? A、 ArrayList myList=new Object(); List myList=new ArrayList();
C ArrayList myList=new List(); D、 List myList=new List();2.paint()方法使用哪种类型的参数? 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[0]='g'; } }
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(); } }
第一行会产生编译错误 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();
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、 输出空。 A、 \\ B、 *\\ C、 \’ D、 \’\’
10.下列哪些语句关