2022年面向对象的程序设计[整 .pdf

上传人:Q****o 文档编号:28015342 上传时间:2022-07-26 格式:PDF 页数:7 大小:103.60KB
返回 下载 相关 举报
2022年面向对象的程序设计[整 .pdf_第1页
第1页 / 共7页
2022年面向对象的程序设计[整 .pdf_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《2022年面向对象的程序设计[整 .pdf》由会员分享,可在线阅读,更多相关《2022年面向对象的程序设计[整 .pdf(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、中国海洋大学20072008 学年第 2 学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(A 卷) 共 3 页 第 1 页考试说明:本课程为闭卷考试,可携带文具 ( 或本课程为开卷考试,可携带文具和资料) ,满分为: 100 分。一、 ( 20 points)Multiple Choice1. is not a member function of a class. (A) Constructor (B) Destructor (C) Friend function2. is the earliest ancestor of object-oriented programmin

2、g languages. (A) C+ (B) Simula 67 (C) FORTRAN 3.To assert that one class is a of another is to simply say it was built using inheritance. (A) subclass (B) subtype 4. may be accessed directly through the instances of child class within the external function. (A) private members in the parent class (B

3、) protected members in the parent class (C) public members in the parent class 5. To create an instance, the template argument must be associated with a . (A) type (B) number (C) character 6. C+ has the space allocation strategy. (A) maximum static (B) minimum static (C) dynamic 7. In allocation, th

4、e amount of space required is determined at run-time . (A) stack-based (B) heap-based 8. “ ” can be overloaded as function. (A) friend (B) member 9. A is invoked automatically when an object is deleted. (A) constructor (B) destructor10. Overriding is resolved at time. (A) run (B) compile 题号一二三四五六七总分

5、得分授课教师命题教师或命题负责人签字年月日院系负责人签字年月日优选专业年级学号姓名授课教师座号-装-订-线-名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 7 页 - - - - - - - - - 共 3 页第 2 页二、 (10 points)True/False( ) 1. Inheritance represents the has-a relationship. ( ) 2. All the member functions in the friend clas

6、s are friend members for current class. ( ) 3. Shadowing only occurs in the context of the parent/child relationship. ( ) 4. A type name can be used as an operator. ( ) 5. In object-oriented languages, the term polymorphism means there is one meaning and many different names. 三、 ( 16 points) Fill in

7、 the following blanks and write out the running results of function main. Suppose: (1) class Y is a private subclass of class X;(2) class Z is a public subclass of class Y;(3) a, b and c are encapsulated data members. #include class X public: X(int x) a=x; void showX( ) cout“ a=” aendl;int a; ; clas

8、s Y: private X public: Yb=y; void showY( ) couta=aendl; coutb=bendl; X:showX( ); private: int b; ; class Z: public Y public: Z c=z; void showZ( ) showY( ); coutc=cendl; private: int c; ; int main( ) Z obj(10, 20, 30); obj.showX( ); obj.showY( ); obj.showZ( ); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - -

9、 - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 7 页 - - - - - - - - - 中国海洋大学20072008 学年第 2 学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(A 卷) 共 3 页 第 3 页四、 ( 14 points)Please write out the class definitions of Studentand GraduateStudent. 五、 ( 20 points) Please write out the class definitions of Shape , Cu

10、be , Sphereand draw the diagram of inheritance hierarchy. 六、 ( 20 points)Please implement the addition of two matrices, which has 2 rows and 3 columns. 优选专业年级学号姓名授课教师座号-装-订-线-名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 7 页 - - - - - - - - - 中国海洋大学20072008 学年

11、第 2 学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(B 卷) 共 3 页 第 1 页考试说明:本课程为闭卷考试,可携带文具 ( 或本课程为开卷考试,可携带文具和资料) ,满分为: 100 分。一、 ( 12 points)Multiple Choice1. is not a member function of a class. (A) Constructor (B) Destructor (C) Friend function2. is the earliest ancestor of object-oriented programming languages. (A)

12、C+ (B) Simula 67 (C) FORTRAN 3.is a valid identifier in C+. (A) 2006Year (B) E-mail (C) idNumber# (D) _age 4. Storage for variable is allocated at block entry and destroyed at block exit. (A) global (B) static (C) automatic5. may be accessed directly through the instances of child class within the e

13、xternal function. (A) private members in the parent class (B) protected members in the parent class (C) public members in the parent class 6. is a manipulator used to determine the number of character positions in which to display a right-justified number. (A) setw (B) setprecision (C) fixed (D) end

14、l 二、 ( 12 points)True/False( ) 1. Composition represents the is-a relationship. ( ) 2. If the parent class is virtual , there is only one copy in the child classes. ( ) 3. Destructors can be overloaded. ( ) 4. Shadowing only occurs in the context of the parent/child relationship. ( ) 5. Overloading

15、is resolved at run time. ( ) 6. The implementation of dynamic polymorphism relies on virtual functions.题号一二三四五六七总分得分授课教师命题教师或命题负责人签字年月日院系负责人签字年月日优选专业年级学号姓名授课教师座号-装-订-线-名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 7 页 - - - - - - - - - 共 3 页第 2 页三、 ( 16 points

16、)Please fill in the following blanks and write out the running results of function main: #include using namespace std; class Base public: Base(int sa) a=sa; cout“ Constructing Base , a= ” aendl; private: int a; ; class Base1:virtual public Base public: Base1(int sa,int sb): b=sb; cout“ Constructing

17、Base1 , b= ” bendl; private: int b; ; class Base2:virtual public Basepublic: Base2(int sa,int sc): c=sc; cout“ Constructing Base2 , c= ” cendl; private: int c; ; class Derive: public Base1, public Base2 public: Derive(int sa,int sb, int sc,int sd): d=sd; cout“ Constructing Derive, d= ” dendl; privat

18、e: int d; ; int main( ) Derive obj(2, 4, 6, 8); return 0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 7 页 - - - - - - - - - 中国海洋大学20072008 学年第 2 学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(B 卷) 共 3 页 第 3 页四、 ( 20 points)Please implement the addition of two fractional va

19、lues.五、 ( 20 points)Please write out the class definition of PartTime _Student and draw the diagram of inheritance hierarchy. 六、 ( 20 points ) Class person has data members of name, age and sex. Class employee has data members of name, age, sex, department and salary. Both of them can provide servic

20、e to display values of data members. Please write out the definitions of class person and class employee using public inheritance.优选专业年级学号姓名授课教师座号-装-订-线-名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 7 页 - - - - - - - - - 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 7 页 - - - - - - - - -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 技术总结

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁