面向对象程序设计导论(双语)2014~2015学年第2学期-A卷
311020040面向对象程序设计导论_双语_B闭_

311020040 面向对象程序设计导论(双语) (B 闭)
2012-2013-1
a. ASCII b. bytecode c. Unicode d. EBCDIC 10. Objects maintain their own state via a. Their superclass parts b. Their static variables c. Their instance variables d. Their local variables 11. A collection typically models a _____ relationship. a. zero-to-one b. one-to-many c. many-to-many d. one-to-one 12. A relationship that exists between two specific instances of an object is known as ano a. association b. aggregation c. specialization d. link 13. Which of the following statements about constructors in Java is true? a. A class must define at least one constructor. b. A class can define more than one constructor. c. A constructor must be defined as public. d. A constructor must be defined as static. 14. What is used to indicate that a method does not return a value? a. the keyword void b. the name of the class to which it belongs c. the omission of the return type d. the keyword static 15. When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be a. hidden b. overridden c. private d. overloaded 16. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? a. final b. default c. protected d. private 17. If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C? a. int sum(float a, int b) b. int sum(int x, float y) c. int sum(int x, int y) d. float sum(int x, float y) 18. How many lines of output will be produced by the following code fragment? for (int i = 0; i < 4; ++i) { for (int j = 1; j < 3 ; ++j) { stdOut.println(i + j); a. 6 b. 8 c. 10 d. 12 19. Which of the following is a Java event that is generated when the close button on a JFrame component is pressed? a. ExitEvent b. WindowEvent c. CloseEvent d. DisposeEvent 20. Consider the following Java class definitions public class Object1 { protected String d(){ return "Hi"; } } public class Object2 extends Object1 { protected String d(){ return super.d(); }
《面向对象程序设计》试卷A(第三套)课案

湖北第二师范学院2014-2015学年度第一学期课程考试试卷(A卷)课程名称:《面向对象程序设计》考试方式:闭卷(开卷、闭卷)院系:专业班级:学生姓名:学号:一、单项选择题(从下列各题备选答案中选出一个正确的答案,并将其选项填在答题卡上,答在试卷上不得分。
多选、选错或未选者不得分。
每小题1分,共30分)1、下列合法的变量名是()。
(A)8d(B)1_2h(C)_int(D)file.cpp2、有说明语句:int a=0; double x=5.16; ,则以下语句中,( )属于编译错误。
(A)x=a/x; (B) x=x/a; (C) a=a%x; (D) x=x*a;3、设有:int a=7,b=5,c=3, d=1; , 则条件表达式a<b?a:c>d?c:d的值为()。
(A)7 (B)5 (C)3 (D)14、设x是—个b00l整的逻辑量.y的值为10,则表达式x&&y的值为( )。
A.1B、0C、与x值相同D、与x值相反5、下列for语句循环的次数是( ) 。
for ( int i=0,x=0; !x && i<=3; i++ )(A)3 (B)4 (C)0 (D)无限6、有函数原型void fun( int * ); 下面选项中,正确的调用是( )。
(A)double x = 0.12; fun( &x );(B)int a = 1 ; fun( a*3.14 );(C)int b = 10; fun( &b );(D)fun( 56 );7、关于函数定义和调用的说法正确的是( )。
(A)函数能嵌套调用,但不能嵌套定义(B)函数能嵌套调用,也能嵌套定义(C)函数不能嵌套调用,也不能嵌套定义(D)函数不能嵌套调用,但能嵌套定义8、有定义一维数组语句:int a[5],*p;,则下列表达式错误的是()。
(A)p=p+1(B)a=a+1(C)p-a(D)a+29、假定有语句:int b[][3]={{1},{1,2},{1,2,3},{0}}; 则b[2][2]的值是()。
上海大学14-15级C++试题,DOC

cout<<linkC<<endl;
return0;
}
三、阅读程序写出运行结果(每行1分,共25分)
1.(7分)有关构造与析构的顺序
#include<iostream>
usingnamespacestd;
classTest
{
public:
Test(inta=0,intb=0):x(a),y(b){}
上海大学2014~2015学年度秋季学期试卷(A卷)
课程名:面向对象程序设计课程号:08305121学分:5
应试人声明:
我保证遵守《上海大学学生手册》中的《上海大学考场规则》,如有考试违纪、作弊行为,愿意接受《上海大学学生考试违纪、作弊行为界定及处分规定》的纪律处分。
应试人应试人学号应试人所在院系
题号
#include<iomanip>
constunsignedlonglongLLINT::BBILLION=
//静态常量数据成员的定义及初始化(10^18)
LLINT::LLINT(unsignedlonglongx0,unsignedlonglongx1)
{//构造函数
unsignedlonglongx=x0/BBILLION;
{
Complexc;
c._x=a._x+b._x;
c._y=a._y+b._y;
returnc;
}
friendComplexoperator*(constComplex&a,constComplex&b)
{
Complexc;
c._x=a._x*b._x-a._y*b._y;
面向对象的程序设计A卷答案

学年第学期考试科目:面向对象的程序设计考试类型:(闭卷)考试时间:120 分钟学号姓名年级专业一、选择题(单选,每题2分,共30分)二、判断题(正确的画勾,错误的画叉)三、简答题1、什么是标识符?什么是保留字?java中标识符的命名规则是?(6分)答:编写程序的时候使用的各种单词称为标识符。
在编程语言中有特殊意义的标识符称为保留字。
Java语言中程序自定义的标识符何以是任何字母、数字、下划线(_)和美元符号($)的组合,但不能以数字开头。
2、按要求完成下面问题。
(8分)(1) 编写一条赋值语句,计算num1、num2之和的平方根,并将结果保存在num3中。
(2分)(2) 方法hypotenuse 带两个参数,第一个参数是整型数据side1,第二个是浮点型参数side2. 并且返回一个双精度浮点型结果。
(3分)(3) Object类的意义是什么?(3分)(1)num3=Math.sqrt(num1+num2);(2)double thpotenuse(int side1, float side2);(3)java中所有类都是直接或者间接地有object类派生,因此object类的所有public方法可供每个对象使用。
3、编写一个方法isIsosceles,以表示三角形的三边长的三个整数为参数,如果该三角形是等腰三角形则返回true,其他情况返回false。
(6分)public boolean isIsoceles (int side1, int side2, int side3){boolean result = false;if ( (side1 == side2) && side1 != side3) ||(side2 == side3) && side2 != side1) ||(side1 == side3) && side1 != side2) )result = true;return result;}4、声明一个枚举型Season变量,可能的取值是winter、spring、summer和fall (4分)enum Season{ winter, spring, summer, fall}5、什么是多态?如何实现多态?(6分)多态性是指一个引用变量在不同时刻可以指向不同类型的对象。
311020040面向对象程序设计导论_双语_A闭_

一、单项选择题(本大题共30小题,每小题2分,共60分)提示:在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在下表中。
错选、多选或未选均无分。
1、Which method must exist in every Java application?A. mainB. paintC. beginD. init2、Which of the following statements is (are) true about the use of an asterisk (*) in a Java importstatement?I. It does not incur run-time overhead.II. It can be used to import multiple packages with a single statement.III. It can be used to import multiple classes with a single statement.A. I and III onlyB. III onlyC. I onlyD. I, II, and III3、A difference between the methods print and println of the class java.io.PrintWriter is thatA. print inserts a new line at the beginning of its output, but println does notB. println appends a new line to the end of its output, but print does notC. println inserts a new line at the beginning of its output, but print does notD. print appends a new line to the end of its output, but println does not4、Suppose that the integer array list has been declared and initialized as follows:private int[] list = { 10, 20, 30, 40, 50 };public void mystery(int[] array) {int tmp = array[array.length - 1];for (int i = 1; i < array.length; i++) {array[i] = array[i - 1];}array[0] = tmp;}Given this array, what is the effect of calling the method mystery(list)A. 10, 20, 30, 40, 50B. 30, 40, 50, 10, 20C. 20, 30, 40, 50, 10D. 50, 10, 20, 30, 405、According to Javadoc convention, the first sentence of each Javadoc comment should beA. an @version tagB. the order of lines is not importantC. an @author tagD. a summary sentence of the declared class6、Which of the following statements about constructors in Java is true.A. A class must define at least one constructorB. A class can define more than one constructorC. A constructor must be defined as publicD. A constructor must be defined as static7、A collection typically models a _____ relationship.A. one-to-oneB. zero-to-oneC. many-to-manyD. one-to-many8、Consider the following UML class diagram.According to the diagram, which of the following statements is true?A. ClassA and ClassB each contain at least one reference to an instance of ClassC.B. ClassB and ClassC are both subclasses of ClassA.C. ClassA is composed of one instance of ClassB and one or more instances of ClassC.D. ClassB has a one-to-one association with ClassA and a one-to-many association with ClassC.9、If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C?A. int sum(float a, int b)B. int sum(int x, float y)C. int sum(int x, int y)D. float sum(int x, float y)10、R egarding the following declaration, what is the index of the element containing 45?int[] numbers = {-1, 45, 6, 132};A. 1B. 2C. 45D. 011、Consider the following Java program segment.import java.io.*;public class Test {public Test( ) {System.out.println("default");}public Test( int i ) {System.out.println("non-default");}public static void main(String[] args) {Test t = new Test(2);}}Which of the following will be output during execution of the program segment?A. The line of text "non-default"B. The line of text "default"C. The line of text "non-default" followed by the line of text "default"D. The line of text "default" followed by the line of text "non-default"12、If a class contains a constructor, that constructor will be invokedA. each time an object of that class is instantiatedB. once the first time an object of that class is instantiatedC. each time an object of that class goes out of scopeD. once at the beginning of any program that uses that class13、Which is the Java keyword used to denote a class method?A. classB. staticC. privateD. final14、Consider the Java program below.public class Arr{public static void main(String[] args) {int[] a = {1, 2, 3};System.out.println(a[1]);System.out.println(a[3]);}}Which of the following is true about the result of executing the program?A. The number 2 is printed and a run-time exception terminates execution.B. The number 2 is printed and there is no abnormal termination.C. The number 1 is printed and there is no abnormal termination.D. The number 3 is printed and a run-time exception terminates execution.15、Given the following code, how many tokens will be output?StringTokenizer st = new StringTokenizer("this is a test", ”s”);while (st.hasMoreTokens()) {stdOut.println(st.nextToken() );}A. 1B. 0C. 3D. 416、An object that contains methods that traverse a vector linearly from start to finish is known as a(n)A. loopB. iteratorC. intD. Exception17、Consider the following method call, where v is an instance of the class java.util.V ector.v.size();This method call returns the number ofA. bytes used by vB. times that the method v.add has been calledC. V ector objects that have been instantiatedD. elements in the vector represented by v18、Which of the following statements is (are) true about inheritance in Java?I. A class can extend more than one abstract class.II. A class can implement more than one interface.A. II onlyB. NoneC. I and IID. I only19、A design pattern is typically used toA. ensure that code executes at optimal speed during runtimeB. reduce the number of classes in the design of a programC. allow the use of object-orientated concepts in a language that is not object-orientedD describe a practical solution to a common design problem20、Which of the following statements is (are) true in Java?I. An abstract class may contain data fields.II. Interfaces may contain data fields.A. I onlyB. II onlyC. NoneD. I and II21、Which package does not need to be explicitly imported into a Java program?A. java.ioB. ngC. java.utilD. java.awt22、If a file opened for reading does not exist, which of the following events will occur in Java?A. A new file will be created.B. A run-time error will occur.C. A NullPointerException will be raised.D. A FileNotFoundException will be raised.23、In a UML class diagram's representation of a class, the top, middle, and lower rectangularcompartments respectively describe the _____ of the class.A. attributes, methods, and nameB. attributes, methods, and constantsC. name, methods, and attributeD. name, attributes, and methods24、The name of a Java source file ______A. must use the extension .classB. must be the same as the class it defines, ignoring caseC. has no restrictionsD. must be the same as the class it defines, respecting case25、All Java exception classes are derived from the classA. ng.ErrorB. ng.ThrowableC. java.io.IOExceptionD. ng.RuntimeException26、The Strategy design pattern is likely to be useful when implementing which of the following?I. An application that offers several alternate sorting algorithmsII. A simple class to store the address of an organization of which only one instance can be instantiatedA. II onlyB. NoneC. I and IID. I only27、Which of the following statements about Java classes is (are) accurate?I. A class may have only one parent.II. Two or more classes may share a parent.A. I and IIB. NoneC. I onlyD. II only28、Which of the following categorizations can be applied to both the data fields and the methods in aJava class?A. native and non-nativeB. default and non-defaultC. static and non-staticD. abstract and non-abstract29、Which of the following is true about association and aggregation in UML class diagrams?A. Association and aggregation have no meaningful relationship.B. Association is a special form of aggregation.C. Association is the opposite of aggregation.D. Aggregation is a special form of association.30、What will be output when the following Java program segment is executed?int x = 5;int y = 2;System.out.println(“x + y”);A. x + yB. 7C. 5+2D. 52二、编程题(本大题共2小题,共30分)。
面向对象程序设计样卷

面向对象程序设计样卷一、选择题( 本大题共10小题, 每题2分, 共20分)4.在下列定义的引用中, ( B )是错误的。
A. int i;B. int i;int &j = i; float &j=i;C. float i;D. char d;float &j = i; char &e = d;5. 假定BB为一个类,则执行BB y;语句时将自动调用该类的( B )A. 有参构造函数B. 无参构造函数C. 拷贝构造函数D. 赋值重载函数7.下列对派生类的描述中, ( C )是错误的。
A. 一个派生类能够作为另一个派生类的基类B.派生类至少应有一个基类C. 基类中成员访问权限继承到派生类中都保持不变D.派生类成员除了自己定义的成员外, 还包含了它的基类成员10.控制输出格式的控制符中, ( D )是设置输出宽度的。
A.wsB.endsC. setfill()D.setw()二、填空题( 本大题共10小题, 每题2分, 共20分)1.以/*开始, 以*/结束, 在/*和*/之间的部分即为注释。
2.重载函数在参数类型或参数个数上不同, 但函数名和类名_相同。
3. 假如一个类的名称为MyClass, 使用这个类的一个对象初始化该类的另一个对象时, 能够调用__拷贝______构造函数来完成此功能。
4.当删除对象时, 程序自动调用析构函数。
5. 对于每一个类的非静态成员函数, 都有一个隐含的_this_______指针。
8. 抽象类是指类里有一个函数, 是纯嘘函数。
三、改错题( 下面程序或程序段中有一处错误, 请用注释标明错误所在行的出错原因。
本大题共5小题, 每题2分, 共10分) 1. #include<iostream>using namespace std;int main(){ cout<<"This is a program."<<endl;return 0;}2. #include<iostream>using namespace std;int main(){x=3;int y=x*x;cout<<"y="<<y<<"\n";return 0;}3. #include<iostream>using namespace std;class Aa{public:Aa(int i=0){a=i; cout<<"Constructor "<<a<<endl; } ~Aa(){ cout<<"Destructor "<<a<<endl; }void print( ){cout<<a<<endl;}private:int a;};int main(){Aa al(1),a2(2);al.print();cout<<a2.a<<endl;return 0;}4.class A{int a,b;public:A(int aa,int bb=78){a=aa;b=bb;} };int main(){A x(2), y(4,9);return 0;}5. #include<iostream>using namespace std;class Test{public:static int x;};int Test :: x=20;int main(){cout<<Test::x;return 0;}四、程序分析题( 分析程序, 写出运行结果。
(完整word版)2014-2015面向对象程序设计试卷_共9页

研究生院2014-2015学年《面向对象程序设计》考试试卷开卷一、填空(共15分,每空1分)1、编译时的多态性通过__重载__函数实现。
2、面向对象的四个基本特性是_抽象__、__多态性_、__继承性__和_封装性_。
3. 假定AB为一个类,则执行“AB a(2), b[4],*p[4];”语句时调用该类构造函数的次数为__5__。
4.要实现动态联编必须通过对象指针或引用来调用_虚函数_实现。
5.在函数前面用_ inline _保留字修饰时,则表示该函数表为内联函数。
6.如果将一个对象说明为常对象,则通过该对象只能调用它的__公有成员__函数。
7、非成员函数应声明为类的__友元___函数才能访问这个类的private成员。
8、在用class定义一个类时,数据成员和成员函数的默认访问权限是_ 私有____。
9、运算符重载函数可能是类的_友元_函数,也可以是类的_成员_函数,还可以是普通函数。
10、__转换构造函数__函数可以将一个指定的数据转换为类的对象,_类型转换函数_函数实现类的对象转换成其它类型的数据。
二、简答题(共25分,每小题5分)1、什么是类模板,类模板声明的一般形式是什么?答案:类模板是对一批仅仅成员数据类型不同的类的抽象,程序员只要为这一批类所组成的整个类家族创建一个类模板,给出一套程序代码,就可以用来生成多种具体的类,(这类可以看作是类模板的实例),从而大大提高编程的效率。
定义类模板的一般形式是:template <类型名参数名1,类型名参数名2,…>class 类名{类声明体};2、有哪几种继承方式?每种方式的派生类对基类成员的继承性如何?答案:继承方式包括:public、private、protected。
3、简述运算符重载的实现方式有哪几种?给出对应的声明语法形式。
答案:(1)类外定义的运算符重载函数格式为:friend <返回类型> operator <op>(<类型> 参数1,<类型> 参数2) { <函数体> }(2)成员运算符重载函数<返回类型> <类名>::operator <op> (<类型> 参数){ <函数体> }4、写出下面程序的输出结果#include<iostream.h>#include<string.h>class Person{}答案:第1次调用类型转换构造函数!第2次调用类型转换构造函数!调用复制构造函数!OldObjectOldObjectNewObject第1次调用析构函数!OldObject第2次调用析构函数!第3次调用析构函数!5. 写运行结果#include <iostream>using namespace std;class A{};答案:(A,B,C,D)= 31,2,3,4三、改错题(共20分,每小题4分)1. 以下程序可动态分配二维数组并释放内存,且可实现二维指针和一维指针复用,试问程序能否正常运行,如不能运行找出原因并改正之。
深圳大学2014-2015学年《面向对象程序设计》C++期末考试试卷及答案

一、单项选择题(每题2分,共40分)1. ______不是属于面向对象程序设计的特性A. 抽象性B. 数据相关性C. 多态性D. 继承性2. 将对某一类数据的处理算法应用到另一类数据的处理中,要用到C++的______A. 类B. 虚函数C. 运算符重载D. 模板3. C++与C语言最根本的不同之处在于_______A. 使用了类B. 能够实现变量自动初始化C. 支持软件重用D. 支持接口重用4. 动态内存分配的主要目的是_______A. 使程序按动态联编方式运行B. 正确合理的使用内存C. 提高程序的运行速度D. 提高程序的可维护性5. 在C++函数的形参前加const关键字,是为了提高函数的_______A. 数据封装性B. 可理解性C. 可维护性D. 可重用性6. 函数重载的目的是________A. 实现共享B. 使用方便,提高可读性C. 提高速度D. 减少空间7. 从程序片断:char name[] = "C++"; course(name);可判断函数course的调用采用的是_______A. 传值调用B. 带缺省参数值的函数调用C. 引用调用D. 传址调用8. 用来说明类中公有成员的关键字是________A. publicB. privateC. protectedD. friend9. 如果一个类的成员函数print()不修改类的数据成员值,则应将其声明为A. void print() const;B. const void print();C. void const print();D. void print(const);10. 下列关于构造函数的论述中,不正确的是_______A. 构造函数的函数名与类名相同B. 构造函数可以设置默认参数C. 构造函数的返回类型缺省为int型D. 构造函数可以重载11. 在程序代码:A::A(int a, int *b) { this->x = a; this->y = b; }中,this的类型是______A. intB. int *C. AD. A *12. 内存泄漏是指_______A. 内存中的数据出现丢失B.试图释放一个已经释放了的动态分配的堆内存C. 函数中局部变量所占的栈内存没有及时回收D. 动态分配的堆内存在程序退出后始终被占用13. 从程序片断:student zhangsan("张三","M",22); zhangsan.id("2005131000");可判断id是一个________A. 私有成员数据B. 私有成员函数C. 公有成员数据D. 公有成员函数14. 友元函数_______A. 可以被声明为constB. 没有this指针C. 可以用类名或对象名来调用D. 只能用对象名来调用15. 若一个类的成员函数前用static关键字修饰,则该成员函数________A. 可以被声明为constB. 没有this指针C. 可以访问该类的所有成员D. 只能用对象名来调用16. C++是用_______实现接口重用的A. 内联函数B. 虚函数C. 重载函数D. 模板函数17. 公有继承的派生类对象可以访问其基类的________A. 公有成员B. 公有成员及受保护成员C. 受保护成员D. 私有成员18. 设置虚基类的目的是________A. 简化程序B. 使程序按动态联编方式运行C. 提高程序运行效率D. 消除二义性19. 下列关于纯虚函数和抽象类的描述中,不正确的是________A. 纯虚函数是一个没有具体实现的虚函数B. 抽象类是包括纯虚函数的类C. 抽象类只能作为基类,其纯虚函数的实现在派生类中给出D. 可以定义一个抽象类的对象20. 关于运算符重载的不正确的描述是________A. 运算符重载函数是友元函数B. 体现了程序设计的多态性C. 增加新的运算符D. 使运算符能对对象操作二、下面的程序是关于CBook类的一个定义,试改正程序中的错误。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1. The return type for a method that returns nothing to its caller is
(a) not specified in the method definition (b) void (c) null (d) false
(a) allow the use of object-orientated concepts in a language that is not object-oriented
(b) ensure that code executes at optimal speed during runtime
(a) It ensures that only one instance of a class is created.
(b) It describes classes that have only one method.
(c) It describes classes that have only one instance variable.
(b) only available through a typical debugger's step into feature
(c) a fatal error that causes a typical debugger to terminate
(d) a list of variables allocated on a program's stack
✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈✈
评阅教师 得分
一、单项选择题(本大题共 30 小题,每小题 1 分,共 30 分)
提示:在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在 下表中。错选、多选或未选均无分。
1
2
3
4
5
6
7
8
9
10ቤተ መጻሕፍቲ ባይዱ
11
12
(a) 0, n-1
(b) 1, n
(c) 0, n
(d) 1, n-1
注: 试题字迹务必清 晰,书 写工整 。
本题共 12 页,本页为第 1 页 教务处试题编号:311 -
课程名称 :
任课教师 :
学号:
姓名:
4. Consider the Java program below.
public class Arr { public static void main(String[] args) { int[] a = {1, 2, 3}; System.out.println(a[1]); System.out.println(a[3]); }
(d) a summary sentence of the declared entry
7. Which of the following methods is (are) provided by java.util.Iterator?
I. next, which causes an iterator to return the next item in its iteration
(c) describe a practical solution to a common design problem
(d) reduce the number of classes in the design of a program
15.Which of the following is true of the Singleton design pattern?
I.It contains no definition.
II.It cannot be declared public.
(a) None
(b) I only
(c) I and II
(d) II only
9. Which of the following statements about Java classes is (are) accurate?
2. If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C?
(a) float sum(int x, float y)
II. remove, which can remove an item from a collection associated with an iterator
(a) II only
(b) I and II
(c) I only
(d) None
8. Which of the following statements is (are) true about any abstract method in Java?
(a) attributes, methods, and name (b) attributes, methods, and constants
(c) name, attributes, and methods (d) name, methods, and constants
14. A design pattern is typically used to
四川大学各级各类考试的监考人员,必须严格执行《四川大学考试工作管理办法》、《四川大学考场规则》和《四川大学监考 人员职责》。有违反学校有关规定的,严格按照《四川大学教学事故认定及处理办法》进行处理。
题 号 一(30%) 二(30%) 三(40%)
卷面成绩
得分 阅卷时间
注意事项:1. 请务必将本人所在学院、姓名、学号、任课教师姓名等信息准确填写在试题纸和添卷纸上; 2. 请将答案全部填写在本试题纸上; 3. 考试结束,请将试题纸、添卷纸和草稿纸一并交给监考老师。
(a) Dynamic Binding (b) Polymorphism (c) Inheritance (d) Encapsulation
18. What are valid arguments to the instanceof operator?
(a) a class object and a class type
(a) Decorator
(b) Singleton
(c) Composite
(d) Strategy
注: 试题字迹务必清 晰,书 写工整 。
本题共 12 页,本页为第 3 页 教务处试 题编号 :
课程名称 :
任课教师 :
学号:
姓名:
17. Which of the following characteristics of an object-oriented programming language restricts behavior so that an object can only perform actions that are defined for its class?
} Which of the following is true about the result of executing the program? (a) The number 1 is printed and there is no abnormal termination. (b) The number 2 is printed and there is no abnormal termination. (c) The number 2 is printed and a run-time exception terminates execution. (d) The number 3 is printed and a run-time exception terminates execution. 5. A stack trace is (a) a sequence of method calls
(b) I only
(c) I and II
(d) II only
10. A design pattern used to enhance the functionality of an object is
(a) Decorator
(b) Singleton
(c) Composite
(d) Strategy
6. According to Javadoc convention, the first sentence of each Javadoc comment should be
(a) an @version tag
(b) the order of lines is not important
(c) an @author tag
(d) It ensures that the methods of a class are called by only one other class.
16. In which of the following design patterns is a family of algorithms encapsulated into individual but interchangeable classes?
(b) int sum(float a, int b)
(c) int sum(int x, int y)