当前位置:
文档之家› 面向对象技术模拟试卷+-+2015
面向对象技术模拟试卷+-+2015
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.
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.
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
4
4、设应用程序中有一个数据录入界面,如下图所示。程序中有一个上题 3 中 seaweedSet 类对 象 set 属性,保存用户输入的所有 Seaweed 类信息。试完成: (1)当用户单击“添加(Append)”按钮时,创建 Seaweed 类的对象 seaweed,添加的数据插 入到图中的表格中,并将相关信息存入该对象,将其添加到 set 对象中; (2)当用户单击“关闭(Close)”按钮时,将 set 中的 Seaweed 类的对象信息通过控制台显示 出来。请完成“添加(Append)”、“关闭(Close)”按钮单击事件。 (3)简述 JAVA 的事件对象模型、常用的事件监听器接口。如何注册事件监听器?
的方法或程序块用关键字________来限制。
A.notify
B.wait
C.synchronized
D.notifyAll
8 JAVA UDP 编程主要用到的两个类型是_____ __和________。发送和接收信息的方法是
______。
A.UDPSocket
B.DatagramSocket
C.UDPPacket
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
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 行不能通过编译,因为只能有一个静态初始化器
}
}
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、设生物信息管理系统中,需要定义一个实体类 Capture 表示生物类,要求如下: (1)具有属性生物名称 name、生物的分类 Catalog; (2)属性的 setter/geter 方法; (3)构造方法,默认的构造方法将生物初始化为“赤藻(Red Algae),藻类(Algae)”; (4)重写 toString()方法; (5)设计一个接口类 Processable,该接口中一个方法 String print(),输出生物的基本信息;
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、关于以下程序段,正确的说法是( )
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
海参类 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)集合类框架中常用的接口、类的特点及其应用;
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. final class 不能被继承
B. final 变量不能被修改
C. final 成员变量可以在构造方法中赋值 D. final 方法不能被覆盖(overriden)
7 并发控制是多线程编程的难点。一个线程要等待某个条件的满足调用方法_______;通知某一
个处于等待状态线程的方法是________,通知多个的是________;处于等待状态的线程当前调用
苏州科技学院 面向对象技术 模拟试卷
一、选择题(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.下列程序的运行结果是 public class X extends Thread implements Runable{
public void run(){ System.out.println("this is run()");
} public static void main(String args[]) {
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. Systeeded”);
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