【计算机类职业资格】二级C++笔试52及答案解析.doc
《【计算机类职业资格】二级C++笔试52及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C++笔试52及答案解析.doc(14页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C+笔试 52 及答案解析(总分:88.00,做题时间:90 分钟)一、B选择题/B(总题数:30,分数:60.00)1.若有以下程序: #include iostream using namespace std; class Base private: int a,b; public: Base(int x, int y) a=x; b=y; void show() couta“, “bend1; ; class Derive : public Base private: int c, d; public: Derive(int x,int y, int z,int m):Base(x
2、,y) c=z; d=m; void show() coutc“, “dend1; ; int main () Base b(50,50),*pb; Derive d(10,20,30, 40); pb= pb-show (); return 0; 招待程序后的输出结果是( )。(分数:2.00)A.10,20B.30,40C.20,30D.50,502.若有以下程序: #include iostream using namespace Std; class sample int i; publiC: sample() void setvalue(int m) i=m; void fun(in
3、t m) i+=m; void disp() coutiend1; ; int main() sample *ps; ps=new sample; ps-setvalue(20); ps-fun(5); ps-disp(); return 0; 程序运行后,输出的结果是( )。(分数:2.00)A.15B.20C.25D.303.下面各选项中,属于非法的 C+整型常量的是( )。(分数:2.00)A.01B.0x11C.081D.-327684.数据是指所有能输入到计算机之中并被计算机程序处理的( )。(分数:2.00)A.文字B.字母C.符号D.数字5.在一棵度为 3 的树中,度为 3 的节
4、点有 2 个,度为 2 的节点有 1 个,度为 1 的节点有 2 个,那么,该树的叶节点数目为( )。(分数:2.00)A.4B.5C.6D.76.若有以下程序: #include iostream using namespace std; class sample private: int x; public: sample() void setx(int i) x=i; friend int fun(sample B,int n) int m=O; for (int i=O; in; i+) if(Bi.xm) m=B i.x; return m; ; int main ( ) sampl
5、e A10; int arr=90,87,42,78,97,84,60,55,78,65; for (int i=O;i10;i+) Ai. setx (arri);coutfun(A, 10)end1; return 0; 该程序运行后的输出结果是( )。(分数:2.00)A.97B.84C.90D.787.若有以下程序: #include iostream using namespace std; class Base public: Base ( ) x=0; int x; ; class Derivedl : virtual public Base public: Derivedl (
6、) x=10; ; class Derived2 : virtual public Base public: Derived2 () x=20; ; class Derived : public Derivedl,protected Derived2 ; int main ( ) Derived obj; coutobj .xend1; return 0; 该程序运行后的输出结果是 ( )。(分数:2.00)A.20B.30C.10D.08.信息隐蔽的概念与下述哪一种概念直接相关( )。(分数:2.00)A.软件结构定义B.模块独立性C.模块类型划分D.模块耦合度9.下列关于软件工程概念的描述
7、中,错误的是( )。(分数:2.00)A.软件工程概念的出现源自软件危机B.软件工程就是试图用工程、科学和数学的原理与方法研制,维护计算机软件的有关技术及管理方法C.软件工程包括 3 个要素,即方法、工具和过程D.软件工程不重视在软件开发过程中应用工程化原则10.设有以下程序段: int a5=0,*p,*q; p=a; q=a; 则下列选项中,合法的运算是( )。(分数:2.00)A.p+qB.p-qC.p*qD.p%q11.若有以下程序: #include iostream using namespace Std; int main() int i ; int a3 3 = 1,2,3,4
8、,5,6,7,8,9; for(i=0;i3;i+) coutai 1“ “; coutend1; return 0; 执行后的输出结果是( )。(分数:2.00)A.50 53 56B.49 52 55C.2 5 8D.1 4 712.若有以下定义: int a =1,2,3,4,5,6,7; char c1=b,C2=2; 则数值不为 2 的表达式是( )。(分数:2.00)A.a1B.d-c1C.a3-c2D.c2-013.以下说法中,不正确的是( )。(分数:2.00)A.C+程序中必须有一个主函数 main(),而且是从 main()的第 1 条语句开始执行的B.非主函数都是在执行主
9、函数时,通过函数调用或嵌套调用而得以执行的C.主函数可以在任何地方出现D.主函数必须出现在固定位置。14.下列叙述中,不正确的是( )。(分数:2.00)A.一个数据结构中的元素在计算机存储空间中的位置关系与逻辑关系可能不同B.一个数据结构中的元素在计算机存储空间中的位置关系与逻辑关系一定不同C.数据的存储结构,也称数据的物理结构。D.数据的存储结构与数据的逻辑结构是不同的15.有以下程序: #include iostream using namespace Std; int a; int fun(); int main() extern int a; int b; a = 100; b =
10、fun(); coutbend1; return 0; int fun() extern int a; return (10*A); 其程序运行后的输出结果是( )。(分数:2.00)A.100B.10C.1000D.1000016.若有如下程序: #include iostream using namespaces std; int s=0; class sample, static int n; public: sample(int i) n=i; static void add() s+=n; ; int sample:s=0; int main() sample a(2),b(5);
11、sample:add(); coutsend1; return 0; 程序运行后的输出结果是( )。(分数:2.00)A.2B.5C.7D.317.下列打开文件的表达式中,错误的是( )。(分数:2.00)A.ofstream ofile; ofilopen(“C:/vc/abtxt“,ios: :binar;B.fstream iofile; iofilopen(“abtxt“,ios:at;C.ifstream ifile(“C:/vc/abtxt“);D.couopen(“C:/vc/abtxt“,ios: :binar;18.模板函数的真正代码是在( )时候产生。(分数:2.00)A.
12、源程序中声明函数时B.源程序中定义函数时C.源程序中调用函数时D.运行执行函数时19.有如下程序: #include iostream using namespace std; int b=3; int fun(int *k) int b=2; b=*(k+)*b; return(B) ; int main() int a ;11,12,13,14,15,16); b=fun( class data public: int x; data (int x) data: :x=x; ; class A private: data d1; public: A(int x) : d1 (x) void
13、 dispa() coutd1, x“, “; ; class B: public A private: data d2; public: B(int x) : A(x-1),d2(x) void dispb() coutd2.xend1; ; class C : public B public: C(int x) : B(x-1) void disp () dispa ( ); dispb (); ; int main ( ) C obj (5); obj.disp(); return 0; 程序执行后的输出结果是( )。(分数:2.00)A.5,5B.4,5C.3,4D.4,3二、B填空题
14、/B(总题数:14,分数:28.00)31.在一个有 n 个元素的顺序表的第 i 个元素(1in)之前插入一个新元素时,需要向后移动U 【1】 /U个元素(分数:2.00)填空项 1:_32.在面向对象方法中,类之间共享属性和操作的机制称为U 【2】 /U。(分数:2.00)填空项 1:_33.源程序文档化要求程序应加注释。注释一般分为序言性注释和U 【3】 /U。(分数:2.00)填空项 1:_34.强行排错法涉及的调试技术主要是U 【4】 /U和监视表达式。(分数:2.00)填空项 1:_35.数据库的设计通常可以分为这样 4 个步骤:需求分析、概念设计、U 【5】 /U和物理设计。(分数
15、:2.00)填空项 1:_36.若有以下程序: #include iostream using namespace std; int main() char a; a=H-A+0; coutaend1; return 0; 执行后输出的结果是U 【6】 /U。(分数:2.00)填空项 1:_37.若二维数组 b 有 m 列,则在 bij前的元素的个数为U 【7】 /U。(分数:2.00)填空项 1:_38.若有如下程序段: #include iostream using namespace std; int main() char *p=“abcdefgh“,*r; long *q; q=(l
16、ong *)p;q+; r=(char *)q; coutrend1; return 0; 该程序的输出结果是U 【8】 /U。(分数:2.00)填空项 1:_39.以下程序的输出结果是U 【9】 /U。 #include iostream using namespace std; void fun() static int a=0; a+=2; couta; int main() int CC; for(CC=1;cc4;CC+) fun(); coutend1; return 0; (分数:2.00)填空项 1:_40.假定用户没有给一个名为 MyClass 的类定义析构函数,则系统为其定
17、义的默认析构函数首部形式为U【10】 /U。(分数:2.00)填空项 1:_41.对虚函数的调用有两种方式:U 【11】 /U和U 【12】 /U。(分数:2.00)填空项 1:_42.U【13】 /U使一个函数可以定义成对许多不同数据类型完成同一个任务。(分数:2.00)填空项 1:_43.若有以下程序: #include iostream using namespace std; class Sample private: const int n; public: Sample(int i) :n(i) ) void print() cout“n=“nend1; ; int main()
18、sample a(10); a.print(); return 0; 上述程序运行后的输出结果是U 【14】 /U。(分数:2.00)填空项 1:_44.有以下程序: #include iostream #include fstream using namespace std; int main() ofstream ofile(“D:/test.txt“); if(!ofile) cout“test.txt cant open“end1; return 0; ofile“This book is C+“ “12345end1; ofile.close(); ifstream ifile(“D
19、:/test.txt“); if ( ! ifile) cout“test.txt cant open“end1; return 0; char str80; ifilestr; ifile.close(); coutstrend1; return 1; 程序执行后的输出结果是U 【15】 /U。(分数:2.00)填空项 1:_二级 C+笔试 52 答案解析(总分:88.00,做题时间:90 分钟)一、B选择题/B(总题数:30,分数:60.00)1.若有以下程序: #include iostream using namespace std; class Base private: int a
20、,b; public: Base(int x, int y) a=x; b=y; void show() couta“, “bend1; ; class Derive : public Base private: int c, d; public: Derive(int x,int y, int z,int m):Base(x,y) c=z; d=m; void show() coutc“, “dend1; ; int main () Base b(50,50),*pb; Derive d(10,20,30, 40); pb= pb-show (); return 0; 招待程序后的输出结果是
21、( )。(分数:2.00)A.10,20 B.30,40C.20,30D.50,50解析:解析 本题考核基类指针的使用。本题首先定义了一个基类 Base 和一个由 Base 派生出来的派生类 Derive。在主函数中,定义了一个基类 Base 指针 pb 和基类对象 b,还定义了派生类 Derive 的对象d。然后将派生类对象 d 的地址赋值给指向基类 Base 的指针 pb。由于 Derive 是 Base 的子类型,因此允许上述赋值。但这时指针 pb 只能使用从基类 Base 继承的成员,即当 pb 指向 d 对象时,pb-shaw 还是调用基类 Base 的成员函数 show()。所以程
22、序最后输出的对象 d 中对基类成员的初始化值,即 10,20。2.若有以下程序: #include iostream using namespace Std; class sample int i; publiC: sample() void setvalue(int m) i=m; void fun(int m) i+=m; void disp() coutiend1; ; int main() sample *ps; ps=new sample; ps-setvalue(20); ps-fun(5); ps-disp(); return 0; 程序运行后,输出的结果是( )。(分数:2.0
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 笔试 52 答案 解析 DOC
