面向对象程序设计A(JAVA)A.doc_第1页
面向对象程序设计A(JAVA)A.doc_第2页
面向对象程序设计A(JAVA)A.doc_第3页
面向对象程序设计A(JAVA)A.doc_第4页
面向对象程序设计A(JAVA)A.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

班 级 学 号 姓 名 密封装订线 密封装订线 密封装订线XX大学20082009学年第(一)学期考试试卷课程代码 课程名称 面向对象程序设计A(JAVA)考试时间 120分钟题号一二三四五总成绩得分 阅卷教师签字: A卷注意事项:1. 答题前,请先在试卷和机读卡上对应位置用钢笔准确清楚的填写上本人姓名和学号,机读卡的科目栏里填写年级和专业的简称,并用2B铅笔填涂学号(必须填在前8列,剩最右边的一列不填涂);2. 试卷答案必须用2B铅笔在机读卡上按对应题号准确、清楚涂写,答在试卷上无效; 本试卷共65个小题,160小题填写在机读卡上,按【1】【60】的编号顺序涂写。6165题做在答题卷上。【1】【40】每题1分,【41】【60】每题2分。【61】【65】每题4分,做在答题卷上,共100分。一、判断题(本大题共10小题,每小题1分,共10分,正确的填A,错误的填B)1 Java中不能存在同名的两个成员方法。2 实现一个接口,则在类中一定要实现接口中定义的所有方法。3 可以从一个static方法内部发出对非static方法的调用。4 类的构造函数名必须和类名相同。5 Frame默认的布局管理器是BorderLayout。6 Java一个类只能实现一个接口。7 Java语言的一个显著特点就是引入了垃圾回收机制。8 接口中所有方法均为抽象方法。9 类的public类型的成员变量不能被继承。10 用Javac编译Java源文件后得到的文件叫字节码文件。二、单项选择题(本大题共30小题,每小题1分,共30分)在每小题列出的四个选项中,只有一个是符合题目要求的,请将其代码填在后面的答题卷上。错选或未选均无分。11 异常包含下列那些内容?A)程序中的语法错误B)程序的编译错误C)程序执行过程中遇到的事先没有预料到的情况12 D)程序事先定义好的可能出现的意外情况13 下列关于构造方法的叙述中,错误的是 A)Java语言规定构造方法名与类名必须相同 B)Java语言规定构造方法没有返回值,但不用void声明 14 C)Java语言规定构造方法不可以重载 D)Java语言规定构造方法只能通过new自动调用 15 每个Java小应用程序必须定义为 A)Applet 类或JApplet类的子类 B)JFrame类的子类 C)Frame的子类 D)Window的子类 16 在Applet的init()方法被调用后,接下来最先被调用的方法是 A)run() B)start() C)stop() D)destroy() 17 作为Java应用程序图形界面基础的是_。A)PanelB)Frame C)Windows D)Applet 18 Java不允许多重继承,而利用_的设计来达到多重继承的目的。A)类B)接口C)对象D)方法19 下列哪个类声明是正确的?A)abstract final class HI B)abstract private move() C)protected private number; D)public abstract class Car20 Java的核心包中,提供编程应用的基本类的包是 A)Java.applet B) Java.util C)Java.lang D) Java.rmi 21 下列关于Java对import句规定的叙述中,错误的是 A) 在Java程序中import语句可以有多个 B) 在Java程序中import语句可以没有 C) 在Java程序中import语句必须有一个 D) 在Java程序中import语句必须引入在所有类之前 22 下列的哪个选项可以正确用以表示八进制值8? A)0x8 B)0x10 C)08 D)010 23 下列关于继承的哪项叙述是正确的? A)在java中允许多重继承 B)在java中一个类只能实现一个接口 C)在java中一个类不能同时继承一个类和实现一个接口 D)java的单一继承使代码更可靠 24 下列关于Frame类的说法不正确的是 A)Frame是Window类的直接子类 B)Frame对象显示的效果是一个窗口 C)Frame被默认初始化为可见 D)Frame的默认布局管理器为BorderLayout 25 下列Java常见事件类中哪个是鼠标事件类? A)InputEvent B)KeyEvent C)MouseEvent D)WindowEvent 26 下列哪个是面向大型企业级用容器管理专用构件的应用平台? A)J2EE B)J2ME C)J2SE D)J2DE 27 在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数个数、类型或顺序各不相同,传回的值也可以不相同。这种面向对象程序的特性称为_。A)隐藏B)覆盖C)重载D)封装28 下列InputStream类中哪个方法可以用于关闭流? A)skip( ) B)close( ) C)mark( ) D)reset( ) 29 如果一个Java源程序文件中定义了4个类,则编译后会生成几个.class文件。A)x=1 B)x=2 C)x=3D)x=430 Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object? A)String a B)char a C)String a50 D)Object a50 31 What use to position a Button in a Frame, size of Button is not affected by the Frame size, which Layout Button will be set? A)FlowLayout; B)GridLayout; C)North of BorderLayout D)South of BorderLayout 32 An AWT GUI under exposure condition, which one or more method well be invoke when it redraw? A)paint(); B)update(); C)repaint(); D)drawing(); 33 Select valid identifier of Java: A)user-Name B)%passwd C)3d_game D)$charge 34 Which is the range of char? A)2727-1 B)0216 C)0216-1 D)028 35 The argument for a classs main() method is called args, and the class is invoked as follows. java Example cat What would be the effect of trying to access args0 in the main method? A)The value produced is cat B)The value produced is java C)The value produced is Example D)An object of type ArrayIndexOutofBoundsException is thrown. 36 Which contains objects without ordering, duplication, or any particular lookup/retrieval mechanism? A)Map B)Set C)List D)Collection 37 Which correctly create an array of five empty Strings? A)String a5; B)String 5 a; C)String a =, , , , ; D)String a = new String5; for (int i = 0; i 0) j = i * 2; System.out.println ( The value of j is + j ); k = k + 1; A)line 4 B)line 6 C)line 7 D)line 8 48 阅读下面程序 import java.*; public class TypeTransition public static void main(String args)char a=h;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=204 C)aa=97 D)aa=10449 Give the following method: public void example() try unsafe(); System.out.println(“Test1”); catch(SafeException e)System.out.println(“Test 2”); finallySystem.out.println(“Test 3”); System.out.println(“Test 4”); Which dont will display if method unsafe () run normally? A)Test 1 B)Test 2 C)Test 3 D)Test 4 50 The following code is entire contents of a file called Example.java,causes precisely one error during compilation: 1) class SubClass extends BaseClass 2) 3) class BaseClass() 4) String str; 5) public BaseClass() 6) System.out.println(“ok”); 7) public BaseClass(String s) 8) str=s; 9) public class Example 10) public void method() 11)SubClass s=new SubClass(“hello”); 12)BaseClass b=new BaseClass(“world”); 13) 14) Which line would be cause the error? A)9 B)10 C)11 D)12 51 Give this class outline: class Example private int x; /rest of class body Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java? A)Change private int x to public int x B)change private int x to static int x C)Change private int x to protected int x D)change private int x to final int x 52 Give the following class defination inseparate source files: public class Example public Example()/do something protected Example(int i)/do something protected void method()/do something public class Hello extends Example/member method and member variable Which methods are not corrected added to the class Hello? A)public void Example() B)public void method() C)protected void method()D)private void method() 53 Give the code fragment: 1) switch(x) 2) case 1: System.out.println(“Test 1”);break; 3) case 2: 4) case 3: System.out.println(“Test 2”);break; 5) default: System.out.println(“end”); 6) which value of x would cause “Test 1” to the output: A)1 B)2 C)3 D)default 54 Give incompleted method: 1) 2) if(unsafe()/do something 3) else if(safe()/do the other 4) The method unsafe() well throw an IOException, which completes the method of declaration when added at line one? A)public IOException methodName() B)public void methodName() C)public void methodName() throw IOException D)public void methodName() throws IOException 55 Give the code fragment: if(x4) System.out.println(“Test 1”); else if (x9) System.out.println(“Test 2”); else System.out.println(“Test 3”); Which range of value x would produce of output “Test 2”? A)x4 C)x9 D)None 56 Give the following java class: public class Example public static void main(String args) static int x = new int15; System.out.println(x5); 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. 57 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 58 What is written to the standard output given the following statement: System.out.println(5&7); Select the right answer: A)4 B)5 C)6 D)7 59 Look the inheritance relation: person man woman In a source of java have the following line: person p=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 persons object. 60 Give following class: class AClass private long val; public AClass(long v)val=v; public static void main(String args) AClass x=new AClass(10L); AClass y=new AClass(10L); AClass z=y; long a=10L; int b=10; Which expression result is true? A)a!=b; B)a=x; C)y=z; D)x=y; 61 Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java? A)public class Fred B) public class fred public int x = 0; public int x = 0; public Fred (int x) public Fred (int x) this.x=x; this.x=x; C)public class Fred extends MyBaseClass, MyOtherBaseClass public int x = 0; public Fred(int xval) x=xval; D)protected class Fred private int x = 0; private Fred (int xval) x=xval; 62 What happens when you try to compile and run the following program? class Mystery String s; public static void main(String args) Mystery m=new Mystery(); m.go(); void Mystery() s=“constructor”; void go() System.out.println(s); A)this code runs and writes ”null” in the standard output B)this code compliles but throws an exception at runtime C)this code runs but nothing appears in the standard output D)this code runs and “constructor” in the standard output 四、阅读以下程序,写出运行结果(本大题共3小题,每小题4分,共12分)63 import java.io.* ; public class ABC public static void main(String args) int i ; int a = 11,22,33,44,55,66,77,88,99 ; for(i = 0 ; i = a.length / 2 ; i +) System.out.print(ai+aa.length-i-1+ ); System.out.println(); What will be the output?64 public class Flower1 int petalCount = 0; String s; Flower1(int petals) petalCount = petals; System.out.println(Constructor has a int arg only, petalCount= + petalCount); Flower1(String s, int petals) this(petals); this.s = s; System.out.println(String & int args); Flower1() this(hello, 88); System.out.println(default constructor (no args); void print() System.out.println(petalCount = + petalCount + s = + s); public static void main(String args) Flower1 x = new Flower1(); x.print(); What will be the output?65 class StringEditor public static String removeNonLetters(String original) StringBuffer aBuffer = new StringBuffer(original.length(); char aCharacter; for (int i=0; ioriginal.length(); i+) aCharacter = original.charAt(i); if (Character.isLetter(aCharacter) aBuffer.append(new Character(aCharacter); return new String(aBuffer); public class StringEditorTester public static void main(String args) String original = Hello1234, My Name is Mark, 234 I think you are my classmate?!; System.out.println(StringEditor.removeNonLetters(original); What will be the output?五、阅读以下程序,写出程序的功能(本大题共2小题,每小题4分,共8分)66 import java.io.*;public class Ex1public static void main(String args) throws IOExceptionFileInputStream s=new FileInputStream(c:/Hello.txt); int c; while (c = s.read() != -1) System.out.write(c); s.close(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论