面向对象技术模拟试卷+-+2015

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

method on the same object, it is still possible that the first thread might never resume execution.
C. If a thread is blocked in the wait method of an object, and another thread executes the notify
二、判断题(10*1 分=10 分)
1. ( ) 程序中抛出异常时(throw …),只能抛出自己定义的异常对象。 2. ( ) System 类中的 in 是一个输入对象。 3. ( ) 实现一个接口,则在类中一定要实现接口中的所有方法。 4. ( ) 所有的文件输入/输出流都继承于 InputStream 类/OutputStream 类。 5. ( ) 一个异常处理中 finally 语句块只能有一个或者可以没有。 2. ( ) 语句 import JAVA.applet.Applet;最后的 Applet 是代表类(class)。 3. ( ) 类体中 private 修饰的变量在本类中能访问,类生成的对象也能访问。 4. ( ) 线程使用 sleep()方法休眠后,可以用 notify()方法唤醒。 5. ( ) 一个异常处理中 finally 语句块只能有一个或者可以没有。 6. ( )编译语句 int aInt=66666 不会出现编译错误
A. final class 不能被继承
B. final 变量不能被修改
C. final 成员变量可以在构造方法中赋值 D. final 方法不能被覆盖(overriden)
7 并发控制是多线程编程的难点。一个线程要等待某个条件的满足调用方法_______;通知某一
个处于等待状态线程的方法是________,通知多个的是________;处于等待状态的线程当前调用
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
海参类 Seaweed 继承 Capture 类并实现接口 Processable,新的属性 weight 表示重量、color 表示 外观,编写测试类 TestSeaweed,测试类 Seaweed。 [考核要点] (1)类与接口的定义、特点; (2)继承与多态 (3)面向抽象的编程
3、设计上题 2 中的 Seaweed 类对象数据存储方法: (1)设计 Comparator 接口类的子类 MyComparator,实现对 Seaweed 类对象的比较,比较的规 则是 name 的字典顺序(升或降)(其他代码不需要列出); (2)创建 TreeSetDemo.java,在 main()方法中用 MyComparator 为参数,创建一个 SortedSet 接口实现类 TreeSet 的对象 seaweedSet; (3)创建 4 个 Seaweed 类对象,并以存入 seaweedSet; (4)使用迭代器,从 seaweedSet 检索出所有 Seaweed 类对象,调用 Seaweed 类对象中的 print 方法,输出按 name 排序后的信息; [其他数据结构的使用:分别用 Vector、LinkedList、ArrayList、HashSet、HashMap、TreeSet、 TreeMap 类] [考核要点] (1)集合类框架中常用的接口、类的特点及其应用;
method on the same object, then the first thread definitely resumes execution as a direct and sole
consequence of the notify call.
D. If two threads are blocked in the wait method of one object, and another thread executes the
A、行 4 与行 6 都将执行
B、行 4 执行,行 6 不执行
C、行 6 执行,行 4 不执行
C、行 4、行 6 都不执行
5、 如果不做任何处理,那么在多线程访问共享数据时会( )
A、编译出错
B、一定会出问题
1
C、同时访问时一定会出问题
D、同时访问时有可能会出问题
6. 以下描述不正确的是_______。
D. The class File overrides equals() to return true if the contents and type of two separate objects
match.
10. Which statement is true?
A. If only one thread is blocked in the wait method of an object, and another thread executes the
notify
method on the same object, then the first thread that executed the wait call first definitely
resumes
execution as a direct and sole consequence of the notify call.
的方法或程序块用关键字________来限制。
A.notify
B.wait
C.synchronized
D.notifyAll
8 JAVA UDP 编程主要用到的两个类型是_____ __和________。发送和接收信息的方法是
______。
A.UDPSocket
B.DatagramSocket
Байду номын сангаас
C.UDPPacket
5.
static { x/=3;}
6. public static void main(String args[ ])
7. {
8.
System.out.println(“x=“ + x);
9. }
10. }
A、 4 行与 5 行不能通过编译,因为缺少方法名和返回类型
B、 4 行不能通过编译,因为只能有一个静态初始化器
C、 编译通过,执行结果为:x=5
D、编译通过,执行结果为:x=3
3、Java 中如果一个类希望长期保存其状态,则必须实现( )接口
A、Java.io.OutputStream
B、Java.io.无效 Stream
C、java.io.Serializable
D、java.io.Object
4、关于以下程序段,正确的说法是( )
2、设生物信息管理系统中,需要定义一个实体类 Capture 表示生物类,要求如下: (1)具有属性生物名称 name、生物的分类 Catalog; (2)属性的 setter/geter 方法; (3)构造方法,默认的构造方法将生物初始化为“赤藻(Red Algae),藻类(Algae)”; (4)重写 toString()方法; (5)设计一个接口类 Processable,该接口中一个方法 String print(),输出生物的基本信息;
D.DatagramPacket
E.read/write
F.send/receive
9. Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
modify on that same object, then the first thread immediately resumes execution.
B. If a thread is blocked in the wait method of an object, and another thread executes the notify
4
4、设应用程序中有一个数据录入界面,如下图所示。程序中有一个上题 3 中 seaweedSet 类对 象 set 属性,保存用户输入的所有 Seaweed 类信息。试完成: (1)当用户单击“添加(Append)”按钮时,创建 Seaweed 类的对象 seaweed,添加的数据插 入到图中的表格中,并将相关信息存入该对象,将其添加到 set 对象中; (2)当用户单击“关闭(Close)”按钮时,将 set 中的 Seaweed 类的对象信息通过控制台显示 出来。请完成“添加(Append)”、“关闭(Close)”按钮单击事件。 (3)简述 JAVA 的事件对象模型、常用的事件监听器接口。如何注册事件监听器?
三、阅读程序(每题 5 分,共 10 分)
1.下列程序的运行结果是 class A {
public static void main(String[] args) { for(int i=1 ; i < 5 ; i++){ int j = 0; while( j < i){ System.out.println(j + " "); j++; } }
1. String s1="abc"+"def";
2. String s2=new String(s1);
3. if(s1= =s2)
4. System.out.println(“= = succeeded”);
5. if (s1.equals(s2))
6. System.out.println(“.equals() succeeded”);
}
}
A、输出结果为:value is 99.99
B、输出结果为:value is 9
C、输出结果为:value is 9.0
D、编译错误
2、关于以下 Application 的说明,正确的是( )
1. class StaticStuff
2. {
3. static int x=10;
4. static { x+=5;}
} }
2.下列程序的运行结果是 public class X extends Thread implements Runable{
public void run(){ System.out.println("this is run()");
} public static void main(String args[]) {
苏州科技学院 面向对象技术 模拟试卷
一、选择题(10*2 分=20 分)
1、编译运行以下程序后,关于输出结果的说明正确的是 ( )
public class Conditional{
public static void main(String args[ ]){
int x=4;
System.out.println(“value is “ + ((x>4) ? 99.9 : 9));
Thread t=new Thread(new X()); t.start(); } }
运行结果:
四、编程(共 60 分)
1、根据给定的以下 UML 类图,完成: (1)说明图中的类与类之间的关系; (2)根据 UML 类图,设计图中相应的所有类。(10 分)
3
(3)该图描述哪一种设计模式? [考核要点] (1)类与类的关系; (2)UML 类图 (3)常用设计模式
2
7. ( )if(true){int i=17;} System.out.println(i);
运行此程序的结果是输出 17 8. ( )float x=26f; int y=26; int z=x/y; 以上语句能正常编译和运行 9. ( )int x=9; if(x>8 and x<10) System.out.println("true"); 以上语句运行的结果是显示 true 10. ( )String str; System.out.println(str.length()); 以上语句运行的结果是显示 0
相关文档
最新文档