[计算机类试卷]国家二级(C++)机试模拟试卷167及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷167及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷167及答案与解析.doc(32页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 167及答案与解析 一、选择题 1 下列叙述中正确的是 ( )。 ( A)栈是 “先进先出 ”的线性表 ( B)队列是 “先进后出 ”的线性表 ( C)循环队列是非线性结构 ( D)有序线性表既可以采用顺序存储结构,也可以采用链式存储结构 2 支持子程序调用的数据结构是 ( )。 ( A)栈 ( B)树 ( C)队列 ( D)二叉树 3 某二叉树有 5个度为 2的结点,则该二叉树中的叶子结点数是 ( )。 ( A) 10 ( B) 8 ( C) 6 ( D) 4 4 下列排序方法中,最坏情况下比较次数最少的是 ( )。 ( A)冒泡排序 ( B)简单选择排序 (
2、 C)直接插入排序 ( D)堆排序 5 软件按功能可以分为:应用软件、系统软件和支撑软件 (或工具软件 )。下面属于应用软件的是 ( )。 ( A)编译程序 ( B)操作系统 ( C)教务管理系统 ( D)汇编程序 6 下面叙述中错误的是 ( )。 ( A)软件测试的目的是发现错误并改正错误 ( B)对被调试的程序进行 “错误定位 ”是程序调试的必要步骤 ( C)程序调试通常也称为 Debug ( D) 软件测试应严格执行测试计划,排除测试的随意性 7 耦合性和内聚性是对模块独立性度量的两个标准。下列叙述中正确的是 ( )。 ( A)提高耦合性降低内聚性有利于提高模块的独立性 ( B)降低耦合
3、性提高内聚性有利于提高模块的独立性 ( C)耦合性是指一个模块内部各个元素间彼此结合的紧密程度 ( D)内聚性是指模块间互相连接的紧密程度 8 数据库应用系统中的核心问题是 ( )。 ( A)数据库设计 ( B)数据库系统设计 ( C)数据库维护 ( D)数据库管理员培训 9 有两个关系 R, S如下: 由关系 R通过运算得到关系 S,则所使用的运算为 ( )。 ( A)选择 ( B)投影 ( C)插入 ( D)连接 10 将 E-R图转换为关系模式时,实体和联系都可以表示为 ( )。 ( A)属性 ( B)键 ( C)关系 ( D)域 11 字面常量 42、 4 2、 42L的数据类型分别是
4、 ( )。 ( A) long、 double、 int ( B) long、 float、 int ( C) int、 double、 long ( D) int、 float、 long 12 执行下列语句段后,输出字符 “*”的个数 是 ( )。 for(int i=50; i 1; -i) cout *; ( A) 48 ( B) 49 ( C) 50 ( D) 51 13 有如下程序段: int i=0, j=1; nt &r=i; r=j; int*p=&i; *p=&r; 其中会产生编译错误的语句是 ( )。 ( A) ( B) ( C) ( D) 14 必须用一对大括号括起来的
5、程序段是 ( )。 ( A) switch语句中的 case标号语句 ( B) if语句的分支 ( C)循环语句 的循环体 ( D)函数的函数体 15 下列符号中不属于 C+关键字的是 ( )。 ( A) friend ( B) namespace ( C) continue ( D) byte 16 下列有关函数重载的叙述中,错误的是 ( )。 ( A)函数重载就是用相同的函数名定义多个函数 ( B)重载函数的参数列表必须不同 ( C)重载函数的返回值类型必须不同 ( D)重载函数的参数可以带有默认值 17 下列有关运算符重载的叙述中,正确的是 ( )。 ( A)运算符重载是多态性的一种表现
6、 ( B) C+中可以通过运算符重载创造新的运算符 ( C) C+中所有运算符都可以作为非成员函数重载 ( D)重载运算符时可以改变其结合性 18 在下列原型所示的 C+函数中,按 “传值 ”方式传递参数的是 ( )。 ( A) void f1(int x); ( B) void f2(int * x); ( C) void f3(const int * x); ( D) void f4(int &x); 19 将前缀运算符 “-”重载为非成员函数,下列原型中能正确用于类中说明的是( )。 ( A) Deer& operator-(int); ( B) Deer operator-(Deer&
7、, int); ( C) friend Deer& operator-(Deer&); ( D) friend Deer operator-(Deer&, int); 20 有如下函数定义: void func(int a, int& b) a+; b+; 若执行代码段: int x=0, y=1; func(x, y); 则变量 x和 y的值分别是 ( )。 ( A) 0和 1 ( B) 1和 1 ( C) 0和 2 ( D) 1和 2 21 下列运算符中,不能被重载的是 ( )。 ( A) & ( B) != ( C) ( D) + 22 关于运算符重载,下列表述中正确的是 ( )。 (
8、A) C+已有的任何运算符都可以重载 ( B)运算符函数的返回类型不能声明为基本数据类型 ( C)在类型转换符函数的定义中不需要声明返回类型 ( D)可以通过运算符重载来创建 C+中原来没有的运算符 23 下列关于类定义的说法中,正确的是 ( )。 ( A)类定义中包括数据成员和函数成员的声明 ( B)类成员的缺省访问权限是保护的 ( C)数据成员必须被声明为私有的 ( D)成员函数只能在类体外进行定义 24 有如下程序: #include iostream using namespace std; class A public: static int a; void init()a=1; A
9、(int a=2)init(); a+; ; int A: a=0; A obj; int main() cout obj a; return0; 运行时输出的结果是 ( )。 ( A) 0 ( B) 1 ( C) 2 ( D) 3 25 以下关键字不能用来声明类的访问权限的是 ( )。 ( A) public ( B) static ( C) protected ( D) private 26 下列关于派生类构造函数和析构函数的说法中,错误的是 ( )。 ( A)派生类的构造函数会隐含调用基类的构造函数 ( B)如果基类中没有缺省构造函数,那么派生类必须定义构造函数 ( C)在建立派生类对象
10、时,先调用基类的构造函数,再调用派生类的构造函数 ( D)在销毁派生类对象时,先调用基类的析构函数,再调用派生类的析构函数 27 派生类的成员函数不能访问基类的 ( )。 ( A)公有成员和保护成员 ( B)公有成员 ( C)私有成员 ( D)保护成员 28 有如下类定义: class AA int a; Public: AA(int n=0): a(n) ; class BB: public AA public: BB(int n) _ ; 其中横线处的缺失部分是 ( )。 ( A): a(n) ( B): AA(n) ( C) a(n); ( D) a=n; 29 有如下程序: #incl
11、ude iostream using namespace std; class test private: int a; public: test()cout “constructor“ endl; test(int a)cout a endl; test(const test&_test) a=_test a; cout “copy constructor“ endl: test()cout “destructor“ endl; ; int main() test A(3); return0; 执行这个程序的输出结果是 ( )。 ( A) 3 ( B) constructor destruc
12、tor ( C) copy constructor destructor ( D) 3 destructor 30 若有如下类声明: class MyClass public: MyClass()cout 1; ; 执行下列语句 MyClass a, b2, *p2; 程序的输出结果是 ( )。 ( A) 11 ( B) 111 ( C) 1111 ( D) 11111 31 有如下程序: #include iostream using namespace std; class Point public: static int number; public; Point()number+; P
13、oint()number-; ; int Point: number=0; int main() Point*ptr; Point A, B; Point*ptr_point=new Point3; ptr=ptr_point; Point C; cout Point: number endl: deleteptr; return0; 执行这个程序的输出结果是 ( )。 ( A) 3 ( B) 4 ( C) 6 ( D) 7 32 有如下程序: #include iostream using namespace std; class Sample friend long fun(Sample
14、s); public: Sample(long a)x=a; private: long x; ; long fun(Sample s) if(s x 2)return1; return s x*fun(Sample(s x-1); int main() int sum=0; for(int i=0; i 6; i+) sum+=fun(Sample(i); cout sum: return0; 执行这个程序的输出结果是 ( )。 ( A) 120 ( B) 16 ( C) 154 ( D) 34 33 有如下程序: class Base public: int data; ; class D
15、erived1: public Base; class Derived2: protected Base; int main() Derived1 d1; Derived2 d2; d1 data=0; d2 data=0; return0; 下列关于程序编译结果的描述中,正确的是 ( )。 ( A) 皆无编译错误 ( B) 有编译错误, 无编译错误 ( C) 无编译错误, 有编译错误 ( D) 皆有编译错误 34 有如下程序: #include iostream using namespace std; class A public: A(int i)x=i; void dispa()cou
16、t x , ; private: int x; ; class B: public A public: B(int i): A(i+10)x=i; void dispb()dispa(); tout x endl; private: int x; ; int main() B b(2); b dispb(); return0; 执行这个程序的 输出结果是 ( )。 ( A) 10, 2 ( B) 12, 10 ( C) 12, 2 ( D) 2, 2 35 有如下程序: #include iostream using namespace std; class Music public: voi
17、d setTitle(char*str)strcpy(title, str); protected: char type10; private: char title20; ; class Jazz: public Music public: void set(char*str) strcpy(type, “Jazz“); strcpy(title, str); ; 下列叙述中正确的是 ( )。 ( A)程序编译正确 ( B)程序编译时语句 出错 ( C)程序编译时语句 出错 ( D)程序编译时语句 和 都出错 36 有如下程序: #include iostream using namespa
18、ce std; class Book public: Book(char*t=“ “)strcpy(title, t); _ private: char title40; ; class Novel: public Book public: Novel(char*t=“ “): Book(t) char*Category()constreturn“文学 “; ; int main() Book*pb; pb=new Novel(); cout pb- Category(); delete pb; return0; 若程序运行时输出结果是 “文学 ”,则横线处缺失的语句是 ( )。 ( A) c
19、har * Category(); ( B) char * Category()const; ( C) virtual char * Category()const; ( D) virtual char * Category()const=0; 37 如下函数模板: template class T Tsquare(T x)return x*x; 其中 T是 ( )。 ( A)函数形参 ( B)函数实参 ( C)模板形参 ( D)模板实参 38 下列函数模板的定义中,合法的是 ( )。 ( A) template typename T Tabs(T X)return x 0?-X: x; (
20、B) template class T T abs(T x)return x 0?-x: x; ( C) template T class T abs(T x)return x 0?-x: x; ( D) template T abs(T x)return x 0?-x: x; 39 在 C+中, cin是一个 ( )。 ( A)类 ( B)对象 ( C)模板 ( D)函数 40 下列控制格式输入 输出的操作符中,能够设置浮点数精度的是 ( )。 ( A) setprecision ( B) setw ( C) seffill ( D) showpoint 二、基本操作题 41 请使用 VC6
21、或使用【答题】菜单打开考生文件夹 proj1下的工程 proj1。程序中位于每个 “ ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name: Smith Age: 21 ID: 99999 CourseNum: 12 Record: 970 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其他内容。 #include iostream using namespace std; class Studentlnfo protected: ERROR*found* char Name; int Age; int ID: int
22、CourseNum; float Record; public: Studentlnfo(char*name, int Age, int ID, int courseNum, float record); ERROR*found* void Studentlnfo() float AverageRecord() return Record CourseNum; void show()const cout “Name: “ Name “Age: “ Age “ID: “ ID “CoumeNum: “ CourseNum “Record: “ Record endl; ; ERROR*found
23、* Studentlnfo Studentlnfo(char*Name, int Age, int ID, int CourseNum float Record) Name=name; Age=age; this- ID=ID; CourseNum=courseNum; Record=record; int main() Studentlnfo st(“Smith“, 21, 99999, 12, 970); st show(); return0; 三、简单应用题 42 使用 VC6打开考生 文件夹 proj2下的工程 proj2,其中有两个类:一是销售类(sale),用于表示按照一件商品的基
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 167 答案 解析 DOC
