版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- T/GDPPS 011-2024农村环境红火蚁防控技术规程
- T/FJEPEA 1-2025水电机组检修标准项目预算编制规定与计算标准
- T/CI 1068-2025车网互动预约充放电数据管理与分析优化技术规范
- T/CAAMTB 129-2023甲醇汽车用滤清器试验方法
- T/CCAS 057-2025基于影像分析的水泥生产有组织排放中粉尘颗粒物浓度智能监测方法
- T/CASNHP 7-2025中小学校手卫生管理规范
- T/CAME 80-2025骨科机器人远程手术环境配置规范
- DB32/T 5145-2025拟新增耕地土壤污染状况调查技术导则
- (新)医院感染监测报告制度(2篇)
- 仓储公司员工关系专员述职报告
- 员额法官选拔试题及答案
- 住宅项目装饰装修专项施工方案
- 《半条被子一程初心》-纪念中国工农红军长征胜利90周年主题朗诵(长征主题)
- 2026年民航飞行员招飞心理招录测试题含答案
- 教学设计新苏教版科学五上《光源》教学设计
- 《图形的平移和旋转》教案(2课时)-2026-2027学年西南大学版(新教材)小学数学五年级上册
- 《图像的魅力》教学课件-2026-2027学年湘美版(2024)初中美术八年级上册
- 2026届北京海淀区九年级英语中考三模模拟试卷(含答案逐题解析与听力原文)第009套
- 2025年全国农产品质量安全检测技能竞赛理论知识考试题库(含答案)
- 北大青鸟消防控制主机操作知识培训课件
- 景区旅游安全风险评估报告
评论
0/150
提交评论