收藏 分销(赏)

面向对象程序设计A(JAVA)B.doc

上传人:仙人****88 文档编号:9396668 上传时间:2025-03-24 格式:DOC 页数:9 大小:128.50KB 下载积分:10 金币
下载 相关 举报
面向对象程序设计A(JAVA)B.doc_第1页
第1页 / 共9页
面向对象程序设计A(JAVA)B.doc_第2页
第2页 / 共9页


点击查看更多>>
资源描述
班 级 学 号 姓 名 密封装订线 密封装订线 密封装订线 XX大学2008-2009学年第(一)学期考试试卷 课程代码 课程名称 面向对象程序设计A(JAVA)考试时间 120分钟 题号 一 二 三 四 五 总成绩 得分 阅卷教师签字: B卷 注意事项: 1. 答题前,请先在试卷和机读卡上对应位置用钢笔准确清楚的填写上本人姓名和学号,机读卡的科目栏里填写年级和专业的简称,并用2B铅笔填涂学号(必须填在前8列,剩最右边的一列不填涂); 2. 试卷答案必须用2B铅笔在机读卡上按对应题号准确、清楚涂写,答在试卷上无效;  本试卷共65个小题,1~60小题填写在机读卡上,按【1】~【60】的编号顺序涂写。61~65题做在答题卷上。【1】~【40】每题1分,【41】~【60】每题2分。【61】~【65】每题4分,做在答题卷上,共100分。 一、判断题(本大题共10小题,每小题1分,共10分,正确的填A,错误的填B) 1. 数组、类和接口都是引用数据类型。 2. Java语言中一个char类型的数据占用2个字节大小的内存空间。 3. 编译语句Double aDouble = 33.5D; 时不会出现编译错误。 4. 程序中抛出异常时(throw…),只能抛出自己定义的异常对象。 5. 所有的文件输入/输出流都继承于InputStream类/OutputStream类。 6. 一个异常处理中的finally语句可以有多个。 7. Applet程序不能单独运行,需要嵌入在HTML文件中,借助浏览器来解释执行。 8. Java语言在设计C/S程序时,应注意在服务器端使用Socket类来处理客户端的连接请求。 9. 数组是用来存放一批相同类型的对象或数据,当数据的顺序和个数经常发生变动时就要用到向量来存放。 10. 构造函数不能被重载。 二、单项选择题(本大题共30小题,每小题1分,共30分)    在每小题列出的四个选项中,只有一个是符合题目要求的,请将其代码填在后面的答题卷上。错选或未选均无分。   11. 下列哪个属于容器的构件?   A)JFrame B)JButton C)JPnel D)JApplet   12. 如果希望所有的控件在界面上均匀排列,应使用下列那种布局管理器? A)BoxLayout B)GridLayout C)BorderLayout D)FlowLouLayout 13. Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点?   A)安全性  B)多线性  C)跨平台  D)可移植   14. 下列叙述中,错误的是 A)Java Application与Applet所用编译命令相同 B)通常情况下Java Application只能有一个main( )方法 C)Java Applet 必须有HTML文件才能运行 D)Java Applet程序的class文件可用java命令运行 15. 下列事件监听器中,无法对TextField 对象进行事件监听和处理的是 A)ActionListener B)FacusListener C)MouseMotionListener D)ChangeListener 16. 下列关于Applet的安全限制 叙述中,错误的是 A)通常情况下,禁止Applet读写本地文件系统 B)通常情况下,禁止Applet向Applet源主机之外的任何主机建立网络连接 C)通常情况下,禁止Applet读取系统信息 D)通常情况下,禁止Applet加载本地库或方法 17. 下列标识符(名字)命名原则中,正确的是 A)类名的首字母小写 B)变量和方法名的首写字母大写 C)接口名的首写字母小写 D)常量完全大写 18. 作为Java应用程序图形界面基础的是___。 A)Panel B)Frame C)Windows D)Applet 19. Java不允许多重继承,而利用____的设计来达到多重继承的目的。 A)类   B)接口   C)对象 D)方法 20. 下列哪个选项是合法的标识符? A)123 B)_name C)class D)1first 21. 下列关于for循环和while循环的说法中哪个是正确的?   A)while循环能实现的操作,for循环也都能实现     B)while循环判断条件一般是程序结果,for循环判断条件一般是非程序结果     C)两种循环任何时候都可替换     D)两种循环结构中都必须有循环体,循环体不能为空  22. 下列关于Java语言特点的叙述中,错误的是 A)Java是面向过程的编程语言 B)Java支持分布式计算 C)Java是跨平台的编程语言 D)Java支持多线程 23. 下列的哪个赋值语句是不正确的? A)float f = 11.1; B)double d = 5.3E12; C)float d = 3.14f ; D)double f=11.1E10f; 24. 下列的哪个赋值语句是正确的? A)char a=12; B)int a=12.0; C)int a=12.0f; D)int a=(int)12.0; 25. 下列哪个修饰符可以使在一个类中定义的成员变量只能被同一包中的类访问? A)private B)无修饰符 C)public D)protected 26. 在Applet的关键方法中,下列哪个方法是关闭浏览器以释放Applet占用的所有资源? A)init( ) B)start( ) C)paint( ) D)destroy( ) 27. 给出下列代码,则数组初始化中哪项是不正确的? byte[] array1,array2[]; byte array3[][]; byte [][] array4; A)array2 = array1 B)array2=array3 C)array2=array4 D)array3=array4 28. 下列关于内部类的说法不正确的是 A)内部类的类名只能在定义它的类或程序段中或在表达式内部匿名使用 B)内部类可以使用它所在类的静态成员变量和实例成员变量 C)内部类不可以用abstract修饰符定义为抽象类 D)内部类可作为其他类的成员,而且可访问它所在类的成员 29. 顺序执行下列程序语句后,则b的值是 String a="Hello"; String b=a.substring(0,2); A)Hello B)hello C)Hel D)null 30. 下列常见的系统定义的异常中,哪个是输入、输出异常? A)ClassNotFoundException B)IOException C)FileNotFoundException D)UnknownHostException 31. 下列哪个选项是正确计算42度(角度)的余弦值? A)double d=Math.cos(42); B)double d=Math.cosine(42); C)double d=Math.cos(Math.toRadians(42)); D)double d=Math.cos(Math.toDegrees(42)); 32. Which is Java keyword?    A)math    B)null    C)FALSE    D)TRUE 33. Which is the range of int type?    A)-216~216-1    B)- 231~231-1    C)-232~232-1    D)-264~264-1 34. FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream?    A)InputStream    B)OutputStream    C)File    D)RandomAccessFile 35. Which of the following are valid declarations? A) char c= ' \' ' B) char c= "cafe" C) char c= '0xfg' D) char c="\xef" 36. Which statement about the garbage collection mechanism are true?   A)Garbage collection require additional programe code in cases where multiple  threads are running.   B)The garbage collection system never reclaims memory from objects while are still accessible to running user threads.   C)The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.   D)The garbage collection mechanism can free the memory used by Java Object at explection time. 37. Which of the following is true of anonymous innerclass? A) Anonymous inner class can be declared as private,protected or public. B) Anonymous inner class can implement multiple interfaces. C) if not extended or implemented, an anonymous innerclass can become immediate subclass of the outer class or implement an interface. D) if not extended or implemented, an anonymous inner class can become immediate subclass of outer class or implement mutiple interfaces. 38. Which statement is true about an inner class?    A)It must be anonymous    B)It can’t implement an interface    C)It is only accessible in the enclosing class    D)It can access any final variables in any enclosing scope. 39. Which is the main() method return of a application?   A)String   B)byte   C)char   D)void 40. Which is corrected argument of main() method of application?   A)String args   B)String args[]   C)Char args[][]   D)StringBuffer arg[] 三、单项选择题(本大题共20小题,每小题2分,共40分)    在每小题列出的四个选项中,只有一个是符合题目要求的,请将其代码填在后面的答题卷上。错选或未选均无分。 41. 阅读下面代码 if(x==0) { System.out.println(“冠军”); } else if(x>-3) { System.out .println(“季军”); } 若要求打印字符串“季军”,则变量X的取值范围是 A)x!=0&&x>-3   B)x=0   C)x>-3||x!=0   D)x<=-3 42. 假设Foo类有如下定义,设f是Foo类的一个实例,下列语句调用哪个是错误的? public class Foo{ int i; static String s; void imethod(){ } static void smethod(){ } } A)Foo.imethod(); B)f.imethod(); C)System.out.println(f.i); D)Foo.smethod(); 43. 给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void 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. 以下程序运行后的输出结果是: class StaticStuff{ static int x; static {x+=5;} public static void main(String[] args){ System.out.println("x="+x); } static {x%=3;} } A)x=0 B)x=5 C)x=3 D)x=2 45. 阅读下面程序 import java.*; public class TypeTransition{ public static void main(String args[]){ char a='E'; int m=100; int j=97; int aa=a+m; System.out.println("aa="+aa); char bb=(char) j; System.out.println("bb="+bb); } } 如果输出结果的第二行为bb=a,那么第一行的输出是 A)aa=100 B)aa=169 C)aa=97 D)aa=69 46. 下列哪个选项的java源文件代码片段是不正确的? A)package testpackage; B)import java.io.*; public class Test{ } package testpackage; public class Test{ } C)import java.io.*; D) import java.io.*; class Person{ } import java.awt.*; public class Test{ } public class Test{ } 47. Given the following class definition:   class A{   protected int i;   A(int i){   this.i=i;   }   }   which of the following would be a valid inner class for this class?   A)class B{ }    B)class B extends A{ }   C)class B extends A{ D)class B{    B(){System.out.println(“i=” i);} class A{ }    } 48. public class Happy { public static void main(String args[]) { int i=4; int j=2; methodA(i,j); System.out.println(i); } static public void methodA(int i,int j) { i<<=j; } } A) compilation error B) 16 C) 64 D) 4 } 49. Give the following java source fragment:   //point x   public class Interesting{   //do something   }   Which statement is correctly Java syntax at point x?   A)import java.awt.*;   B)package mypackage   C)static int PI=3.14   D)public class MyClass{//do other thing…} 50. Give the following java class:    public class Example{    static int x[]=new int[15];    public static void main(String args[]){    System.out.println(x[5]);    }    }    Which statement is corrected?    A)When compile, some error will occur.    B)When run, some error will occur.    C)Output is zero.   D)Output is null. 51. What is written to the standard output given the following statement:    System.out.println(4&7);    Select the right answer:    A)4    B)5    C)6    D)7 52. What is written to the standard output given the following statement:    System.out.println(7|9);    Select the right answer:    A)0    B)7    C)9    D)15 53. Look the inheritance relation:    person man woman    In a source of java have the following line:    woman w=new man():    What statement are corrected?    A)The expression is illegal.    B)Compile corrected but running wrong.    C)The expression is legal.    D)Will construct a woman object. 54. Which can NOT be used in declaring or declaring and initializing an automatic (method local) variable?    A)final    B)static     C)expressions    D)Constants of non-primitive type 55. Which statements is true about Listeners?    A)At most one listener can be added to any simple Component.    B)The return value from a listener is used to control the invocation of other listener    C)If multiple listeners are added to a single component, they must all be made friends to each other    D)If multiple listeners are added to single component, the order of invocation of the listener is not specifieD) 56. Float s=new Float(0.9F);   Float t=new Float(0.9F);   Double u=new Double(0.9);   Which expression’s result is true?   A)s!=t   B)s.equals(t)   C)s==u   D) t.equals(u) 57. Give the following method:   1) public void method( ){   2) String x,y;   3) x=new String(“hello world”);   4) y=new String(“game over”);   5) System.out.println(x+y+“ok”);   6) x=null;   7) x=y;   8) System.out.println(x);   9) }   In the absence of compiler optimization, which is the earliest point the object x refered is definitely elibile to be garbage collection.   A)before line 5   B)before line 6   C)before line 7   D)Before line 9 58. Given the following class outline:    class Example{    private int x;    // rest of class body    public static void main(String args[]){    //implementation of main method }    }    Which statement is true?    A)x=2 is a valid assignment in the main() method of class Example.    B)Changing private int x to static int x would make x=2 a valid assignment in the main() method of class Example.    C)Changing private int x to public int x would make x=2 a valid assignment in the main() method of class Example.    D)Changing private int x to int x would make x=2 a valid assignment in the main() method of class Example. 59. Give following programe: class EX{ public static void main(String args[]){ outer: for(int i=0; i<3; i++ ) inner: for(int j=0; j<3; j ++){ if(j>=1) break outer; System.out.println(j +" and "+ i); } }}    Which will be output?    A)0 and 0 B)0 and 1 C)0 and 2 D)0 and 3 60. What will be the result of attempting to compile and run the following code? abstract class MineBase{ abstract void amethod(); static int i; } public class Mine extends MineBase{ public static void main(String args[]){ int[] ar = new int[5]; for(i=0; i<ar.length; i++) System.out.println(ar[i]); } } A)a sequence of 5 0’s will be printed B)Error: ar is used before it is initialized C)Error Mine must be declared abstract D)IndexOutOfBoundes Error 四、阅读以下程序,写出运行结果或功能(本大题共5小题,每小题4分,共20分) 61. import java.io.*; public class Test1{ public static void main(String[] args){ Loop: for(int i=1;i<15;i++) {if(i%3!=0) continue Loop; System.out.printf(i+" "); } } }  What will be the output? 3 6 9 12 62. import java.io.*; public class Test{ public static void main(String args[]){ String s1 = "Hi!"; String s2 = new String("How are you!"); System.out.println(s1+" "+s2); } }  What will be the output? Hi! How are you! 63. class Rock { Rock() { System.out.println("Creating Rock"); } } public class SimpleConstructor { public static void main(String[] args) { new Rock(); } }  What will be the output? Creating Rock 64. import java.io.*; class MyException extends Exception{ public String toString(){ return "negative number"; } } public class ExceptionDemo{ public static void mySqrt(int a) throws MyException{ if(a<0) throw new MyException(); System.out.println(Math.sqrt(a)); } public static void main(String args[]){ try{ mySqrt(16); mySqrt(-16); }catch(MyException e){ System.out.println("Exception:"+e); } } } What will be the output? 4.0 Exception:negative number 65. 写出以下程序的功能 import java.io.*; public class Reverse{ public static void main(String args[]){ int i,n=10; int a[] = new int[10]; for(i=0;i<n;i++) try{BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); a[i] = Integer.parseInt(br.readLine()); }catch(IOException e) {} for(i=n-1;i>=0;i--) System.out.print(a[i]+" "); System.out.println(); } } 从键盘上输入10个整数,再按输入时的逆序在显示器上输出。 第 9 页 共 9 页(B卷)
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服