【计算机类职业资格】二级C++-18-2及答案解析.doc
《【计算机类职业资格】二级C++-18-2及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C++-18-2及答案解析.doc(29页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C+-18-2 及答案解析(总分:100.00,做题时间:90 分钟)一、选择题(总题数:40,分数:40.00)1.下列叙述中正确的是_。(分数:1.00)A.栈是“先进先出”的线性表B.队列是“先进后出”的线性表C.循环队列是非线性结构D.有序线性表既可以采用顺序存储结构,也可以采用链式存储结构2.支持子程序调用的数据结构是_。(分数:1.00)A栈B树C.队列D.二叉树3.某二叉树有 5 个度为 2 的结点,则该二叉树中的叶子结点数是_。(分数:1.00)A.10B.8C.6D.44.下列排序方法中,最坏情况下比较次数最少的是_。(分数:1.00)A.冒泡排序B.简单选择排序C.直
2、接插入排序D.堆排序5.软件按功能可以分为:应用软件、系统软件和支撑软件(或工具软件)。下面属于应用软件的是_。(分数:1.00)A.编译程序B.操作系统C.教务管理系统D.汇编程序6.下面叙述中错误的是_。(分数:1.00)A.软件测试的目的是发现错误并改正错误B.对被调试的程序进行“错误定位”是程序调试的必要步骤C.程序调试通常也称为 DebugD.软件测试应严格执行测试计划,排除测试的随意性7.耦合性和内聚性是对模块独立性度量的两个标准。下列叙述中正确的是_。(分数:1.00)A.提高耦合性降低内聚性有利于提高模块的独立性B.降低耦合性提高内聚性有利于提高模块的独立性C.耦合性是指一个模
3、块内部各个元素间彼此结合的紧密程度D.内聚性是指模块间互相连接的紧密程度8.数据库应用系统中的核心问题是_。(分数:1.00)A.数据库设计B.数据库系统设计C.数据库维护D.数据库管理员培训9.有两个关系 R,S 如下: R A B C a 3 2 b 0 1 C 2 1 S A B a 3 b 0 C 2 由关系 R 通过运算得到关系 S,则所使用的运算为_。(分数:1.00)A.选择B.投影C.插入D.连接10.将 E-R 图转换为关系模式时,实体和联系都可以表示为_。(分数:1.00)A.属性B键C.关系D域11.字面常量 42、4.2、42L 的数据类型分别是_。(分数:1.00)A
4、.long、double、intB.long、float、intC.int、double、longD.int、float、long12.执行下列语句段后,输出字符“*”的个数是_。 for(int i=50; i1; -i) cout “*“;(分数:1.00)A.48B.49C.50D.5113.有如下程序段: int i=0, j=1; nt / r=j;/ int *p=/ *p=/ 其中会产生编译错误的语句是_。(分数:1.00)A.B.C.D.14.必须用一对大括号括起来的程序段是_。(分数:1.00)A.switch 语句中的 case 标号语句B.if 语句的分支C.循环语句的循
5、环体D.函数的函数体15.下列符号中不属于 C+关键字的是_。(分数:1.00)A.friendB.namespaceC.continueD.byte16.下列有关函数重载的叙述中,错误的是_。(分数:1.00)A.函数重载就是用相同的函数名定义多个函数B.重载函数的参数列表必须不同C.重载函数的返回值类型必须不同D.重载函数的参数可以带有默认值17.下列有关运算符重载的叙述中,正确的是_。(分数:1.00)A.运算符重载是多态性的一种表现B.C+中可以通过运算符重载创造新的运算符C.C+中所有运算符都可以作为非成员函数重载D.重载运算符时可以改变其结合性18.在下列原型所示的 C+函数中,按
6、“传值”方式传递参数的是_。(分数:1.00)A.void f1(int x);B.void f2(int *x);C.void f3(const int *x);D.void f4(int 19.将前缀运算符“- -”重载为非成员函数,下列原型中能正确用于类中说明的是_。(分数:1.00)A.DecrB.Decr operator -(DecrC.friend DecrD.friend Decr operator -(Decr20.有如下函数定义: void func(int a, int b+; 若执行代码段: int x=0, y=1; func(x, y); 则变量 x 和 y 的值分
7、别是_。(分数:1.00)A.0 和 1B.1 和 1C.0 和 2D.1 和 221.下列运算符中,不能被重载的是_。(分数:1.00)A. class A public: static int a; void init() a=1; A(int a=2) init(); a+; ; int A:a=0: A obj; int main() coutobj. a; return 0; 运行时输出的结果是_。(分数:1.00)A.0B.1C.2D.325.以下关键字不能用来声明类的访问权限的是_。(分数:1.00)A.publicB.staticC.protectedD.private26.下
8、列关于派生类构造函数和析构函数的说法中,错误的是_。(分数:1.00)A.派生类的构造函数会隐含调用基类的构造函数B.如果基类中没有缺省构造函数,那么派生类必须定义构造函数C.在建立派生类对象时,先调用基类的构造函数,再调用派生类的构造函数D.在销毁派生类对象时,先调用基类的析构函数,再调用派生类的析构函数27.派生类的成员函数不能访问基类的_。(分数:1.00)A.公有成员和保护成员B.公有成员C.私有成员D.保护成员28.有如下类定义: class AA int a; Public: AA(int n=0): a(n) ; class BB: public AA public: BB(in
9、t n) ; 其中横线处的缺失部分是_。(分数:1.00)A.: a(n) B.: AA(n) C.a(n);D.a=n;29.有如下程序: #includeiostream using namespace std; class test private: int a; public: test() cout“constructor“endl; test(int a) coutaendl; test(const test cout“copy constructor“endl; test() cout“destructor“endl; ; int main() test A(3); return
10、 0; 执行这个程序的输出结果是_。 A3 B C D (分数:1.00)A.B.C.D.30.若有如下类声明: class MyClass public: MyClass() cout1; ; 执行下列语句 MyClass a, b2, *p2; 程序的输出结果是_。(分数:1.00)A.11B.111C.1111D.1111131.有如下程序: #includeiostream using namespace std; class Point public: static int number; public: Point() number+; Point() number -; ; in
11、t Point:number=0; int main() Point *ptr; Point A, B; Point *ptr_point=new Point3; ptr=ptr_point; Point C; coutPoint:numberendl; deleteptr; return 0; 执行这个程序的输出结果是_。(分数:1.00)A.3B.4C.6D.732.有如下程序: #includeiostream using namespace std; class Sample friend long fun(Sample s); public: Sample(long a) x=a;
12、private: long x; ; long fun(Sample s) if(s. x2)return 1; return s. x*fun(Sample(s. x-1); int main() int sum=0; for(int i=0; i6; i+) sum +=fun(Sample(i); coutsum; return 0; 执行这个程序的输出结果是_。(分数:1.00)A.120B.16C.154D.3433.有如下程序: class Base public: int data; ; class Derivedl: public Base ; class Derived2:
13、protected Base ; int main() Derivedl d1; Derived2 d2; d1. data=0;/ d2. data=0;/ return 0; 下列关于程序编译结果的描述中,正确的是_。(分数:1.00)A.皆无编译错误B.有编译错误,无编译错误C.无编译错误,有编译错误D.皆有编译错误34.有如下程序: #includeiostream using namespace std; class A public: A(int i) x=i; void dispa() coutx“,“; private: int x; ; class B: public A p
14、ublic: B(int i): A(i+10) x=i; void dispb() dispa(); coutxendl; private: int x; ; int main() B b(2); b. dispb(); return 0; 执行这个程序的输出结果是_。(分数:1.00)A.10, 2B.12, 10C.12,2D.2, 235.有如下程序: #includeiostream using namespace std; class Music public: void setTitle(char*str) strcpy(title, str); protected: char
15、type10; private: char title20; ; class Jazz: public Music public: void set(char*str) strcpy(type, “Jazz“);/ strcpy(title, str);/ ; 下列叙述中正确的是_。(分数:1.00)A.程序编译正确B.程序编译时语句出错C.程序编译时语句出错D.程序编译时语句和都出错36.有如下程序: #includeiostrcam using namespace std; class Book public: Book(char* t=“ “) strcpy(title, t); pri
16、vate: char title40; ; class Novel: public Book public: Novel(char* t=“ “): Book(t) char*Category()const return“文学“; ; int main() Book *pb; pb=new Novel(); coutpb-Category(); delete pb; return 0; 若程序运行时输出结果是“文学”,则横线处缺失的语句是_。(分数:1.00)A.char*Category();B.char*Category()const;C.virtual char*Category()co
17、nst;D.virtual char*Category()const=0;37.如下函数模板: templateclass TT square(T x) return x*x; 其中 T 是_。(分数:1.00)A.函数形参B.函数实参C.模板形参D.模板实参38.下列函数模板的定义中,合法的是_。(分数:1.00)A.templatetypename TT abs(T x) return x0? -x: x;B.template classTT abs(T x) return x0? -x: x;C.template Tclass Tabs(T x) return x0? -x: x;D.t
18、emplate T abs(T x) return x0? -x: x;39.在 C+中,cin 是一个_。(分数:1.00)A类B.对象C.模板D.函数40.下列控制格式输入/输出的操作符中,能够设置浮点数精度的是_。(分数:1.00)A.setprecisionB.setwC.setfillD.showpoint二、基本操作题(总题数:1,分数:18.00)41.请使用 VC6 或使用答题菜单打开 proj1 下的工程 proj1,此工程中含有一个源程序文件 proj1. cpp。其中位于每个注释“/ERROR *found*”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:
19、Constructor called. The value is 10 Copy constructor called. The value is 10 Destructor called. Destructor called. 注意:只修改注释“/ERROR *found*”的下一行语句,不要改动程序中的其他内容。 /proj1. cpp #includeiostream using namespace std; class MyClass public: /ERROR *found* MyClass(int i) value=i; cout“Constructor called.“endl
20、; /ERROR *found* MyClass(const MyClass P) value=P. value; cout“Copy constructor called.“endl: void Print() cout“The value is“valueendl: /ERROR *found* voidMyClass() cout“Destructor called.“endl; private: int value; ; int main() MyClass obj1; obj1. Print(); MyClass obj2(obj1); obj2. Print(); return 0
21、; (分数:18.00)_三、简单应用题(总题数:1,分数:24.00)42.请使用 VC6 或使用答题菜单打开 proj2 下的工程 proj2,其中有矩阵基类 MatrixBase、矩阵类Matrix 和单位阵 UnitMatrix 的定义,还有 main 函数的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 注意:只能在横线处填写适当的代码,不要改
22、动程序中的其他内容,也不要删除或移动“/*found*”。 #includeiostream using namespace std; /矩阵基础类,一个抽象类 class MatrixBase int rows, cols; public: MatrixBase(int rows, int cols): rows(rows), cols(cols) int getRows()const return rows;/矩阵行数 int getCols()const return cols;/矩阵列数 virtual double getElement(int r, int c)const=0;/取
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 C182 答案 解析 DOC
