版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 ancest
2、or of object-oriented programming languages.(A) C+ (B) Simula 67 (C) FORTRAN3. To assert that one class is a of another is to simply say it was built using inheritance. (A) subclass (B) subtype4. may be accessed directly through the instances of child class within the external function. (A) private
3、members in the parent class (B) protected members in the parent class (C) public members in the parent class5. To create an instance, the template argument must be associated with a . (A) type (B) number (C) character6. C+ has the space allocation strategy.(A) maximum static (B) minimum static (C) d
4、ynamic 7. In allocation, the amount of space required is determined at run-time .(A) stack-based (B) heap-based8. “<<” can be overloaded as function. (A) friend (B) member9. A is invoked automatically when an object is deleted.(A) constructor (B) destructor10. Overriding is resolved at time.(A
5、) run (B) compile 授课教师命题教师或命题负责人签字 年 月 日院系负责人签字年 月 日共3页 第2页二、(10 points)True/False( ) 1. Inheritance represents the has-a relationship. ( ) 2. All the member functions in the friend class are friend members for current class.( ) 3. Shadowing only occurs in the context of the parent/child relationshi
6、p.( ) 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 the following blanks and write out the running results of function main.Suppose: (1) class Y is a private subclass of c
7、lass X;(2) class Z is a public subclass of class Y;(3) a, b and c are encapsulated data members.#include<iostream> class Xpublic: X(int x) a=x; void showX( )cout<<“a=”<<a<<endl; int a;class Y: private Xpublic: Y b=y;void showY( ) cout<<"a="<<a<<end
8、l; cout<<"b="<<b<<endl; X:showX( );private: int b;class Z: public Ypublic: Z c=z; void showZ( ) showY( ); cout<<"c="<<c<<endl;private: int c;int main( )Z obj(10, 20, 30); obj.showX( ); obj.showY( ); obj.showZ( ); return 0; 中国海洋大学 20072008学年 第2学
9、期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(A卷)优选专业年级 学号 姓名 授课教师 座号 -装-订-线- 共3页 第3页四、(14 points)Please write out the class definitions of Student and GraduateStudent.五、(20 points) Please write out the class definitions of Shape, Cube, Sphere and draw the diagram of inheritance hierarchy.六、(20 points)Please imple
10、ment the addition of two matrices, which has 2 rows and 3 columns.中国海洋大学 20072008学年 第2学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(B卷)优选专业年级 学号 姓名 授课教师 座号 -装-订-线- 共3页 第1页考试说明:本课程为闭卷考试,可携带 文具(或本课程为开卷考试,可携带 文具和 资料),满分为: 100分。 题号一二三四五六七总分得分一、(12 points)Multiple Choice1. is not a member function of a class.(A) Const
11、ructor (B) Destructor (C) Friend function2. is the earliest ancestor of object-oriented programming languages.(A) C+ (B) Simula 67 (C) FORTRAN3. is a valid identifier in C+.(A) 2006Year (B) E-mail (C) idNumber# (D) _age4. Storage for variable is allocated at block entry and destroyed at block exit.(
12、A) global (B) static (C) automatic5. may be accessed directly through the instances of child class within the external 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 o
13、f character positions in which to display a right-justified number.(A) setw (B) setprecision (C) fixed (D) endl 二、(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 ov
14、erloaded. ( ) 4. Shadowing only occurs in the context of the parent/child relationship. ( ) 5. Overloading is resolved at run time.( ) 6. The implementation of dynamic polymorphism relies on virtual functions.授课教师命题教师或命题负责人签字 年 月 日院系负责人签字年 月 日共3页 第2页三、(16 points)Please fill in the following blanks a
15、nd write out the running results of function main:#include<iostream>using namespace std;class Basepublic: Base(int sa) a=sa; cout<<“Constructing Base, a=”<<a<<endl;private: int a;class Base1:virtual public Basepublic: Base1(int sa,int sb): b=sb; cout<<“Constructing Base
16、1, b=”<<b<<endl;private: int b;class Base2:virtual public Basepublic: Base2(int sa,int sc): c=sc; cout<<“Constructing Base2, c=”<<c<<endl;private: int c;class Derive: public Base1, public Base2public:Derive(int sa,int sb, int sc,int sd): d=sd;cout<<“Constructing D
17、erive, d=”<<d<<endl;private: int d;int main( )Derive obj(2, 4, 6, 8); return 0;中国海洋大学 20072008学年 第2学期 期末考试试卷信息科学与工程学院面向对象的程序设计课程试题(B卷)优选专业年级 学号 姓名 授课教师 座号 -装-订-线- 共3页 第3页四、(20 points)Please implement the addition of two fractional values.五、(20 points)Please write out the class definition of PartTime _Student and draw the diagram of inheritance hierarchy.六、(20 points)Class person h
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 教学《吃西瓜》数学课件教案
- 元旦主题活动工作计划
- 化疗药物外渗预防及处理
- 交通安全的演讲稿(集锦15篇)
- 2025年农产品初加工成本控制方案行业报告
- 汇丰银行企业-Treasury-部门绩效考核含答案
- 河钢集团总经理考试题库
- 软件研发项目经理面试题及答案解析
- 《农业产业化发展中的农产品市场流通体系建设研究》教学研究课题报告
- 2025菏投热电(巨野)有限公司面向市属企业(内部)选聘运维人员60人笔试参考题库附带答案详解(3卷合一版)
- T-CNHC 4-2025 昌宁县低质低效茶园改造技术规程
- 雨课堂学堂在线学堂云《芊礼-谦循-送给十八岁女大学生的成人之礼(中华女子学院 )》单元测试考核答案
- 2025年手术室护理实践指南试题(含答案)
- 智慧农贸市场建设项目报告与背景分析
- 护理部竞选副主任
- 【10篇】新版部编六年级上册语文课内外阅读理解专项练习题及答案
- 2026年中国经济展望:风鹏正举
- 雨课堂学堂云在线《人工智能原理》单元测试考核答案
- 国开电大本科《人文英语4》机考总题库
- 细胞存活曲线的推导王大奖
- 2023年足球俱乐部试训个人简历
评论
0/150
提交评论