【计算机类职业资格】二级C++笔试77及答案解析.doc
《【计算机类职业资格】二级C++笔试77及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C++笔试77及答案解析.doc(16页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C+笔试 77及答案解析(总分:100.00,做题时间:90 分钟)一、B选择题/B(总题数:35,分数:70.00)1.有以下程序: #include iostream using namespace std; class sample private: iht n; public: sample() sample(int m) n=m; void addvalue(int m) sample s; s.n=n+m; *this=s; void disp() cout“n=“nend1; ; int main() sample s(10); s.addvalue(5); s.disp(
2、); return 0; 程序运行后的输出结果是(分数:2.00)A.n=10B.n=5C.n=15D.n=202.在软件生存周期中,能准确地确定软件系统必须做什么和必须具备哪些功能的阶段是(分数:2.00)A.概要设计B.详细设计C.可行性分析D.需求分析3.下列叙述中正确的是(分数:2.00)A.程序执行的效率与数据的存储结构密切相关B.程序执行的效率只取决于程序的控制结构C.程序执行的效率只取决于所处理的数据量D.以上三种说法都不对4.在 C+语言中函数返回值的类型是由( )决定的。(分数:2.00)A.调用该函数时系统临时B.return语句中的表达式类型C.定义该函数时所指定的函数类
3、型D.调用该函数时的主调函数类型5.关于类和对象描述错误的是(分数:2.00)A.对象(Objec 是现实世界中的客观事物,对象具有确定的属性B.类是具有相同属性和行为的一组对象的集合C.对象是类的抽象,类是对象的实例D.类是对象的抽象,对象是类的实例6.定义如下枚举类型; enum Monday, Tuesday, Wednesday, Thrusday, Friday=2;则下列语句正确的是(分数:2.00)A.表达式 Wednesday = Friday 的值是 trueB.Day day; day=3;C.Day day; day = Monday + 3;D.Day day; day
4、 = Tuesday + 10;7.将 E-R 图转换到关系模式时,实体与联系都可以表示成(分数:2.00)A.属性B.关系C.键D.域8.有以下程序: #include iostream using namespace std; #define PI 3.14 class Point private: int x,y; public: Point(int a,int b) x=a; y=b; int getx() return x; int gety() return y; ; class Circle: public Point private: int r; public: Circle
5、(int a, int b,int c):Point(a,b) r=c; int getr() return r; double area() return PI*r*r; ,int main() Circle c1(5,7,10); coutc1 .area()endl; return0; 程序执行后的输出结果是(分数:2.00)A.314B.157C.78.5D.153.869.若类 A和类 B的定义如下: class A int i,j; public: int geti() return i; ; class B: public A int k; public: void make()
6、 k=i*j ; 则上述定义中非法的语句是(分数:2.00)A.k=i*j;B.int k;C.return i;D.void make()10.有以下程序: #include iostream using namespace std; class A public: A(int i,int j) a=i; b=j; void move(int x,int y) a+=x; b+=y; void show() couta“,“bend1; private: int a,b; ; class B: private A public: B(int i,int j): A(i,j) void fun
7、() move(3,5); void fl () A:show(); ; int main() B d(3,4); d.fun(); d.f1(); return 0; 程序执行后的输出结果是(分数:2.00)A.3,4B.6,8C.6,9D.4,311.有如下函数模板的定义: template class T T func(Tx,Ty) return x*x+y*y;(分数:2.00)A.func(3,5);B.func(3,5);C.func(3,5.5);D.funcint (3,5.5);12.在深度为 5的满二叉树中,叶子结点的个数为(分数:2.00)A.31B.32C.16D.15
8、13.有如下程序: #include iostream using namespace std; int s=0; class sample static int n; public: sample(int i) n=i; static void add() s+=n; ; iht sample:s=0; iht main() sample a(2),b(5); sample:add(); coutsend1; return 0; 程序运行后的输出结果是(分数:2.00)A.2B.5C.7D.314.函数定义为 Fun(int B.Fun(20+;C.Fun(;D.Fun(&;15.下面类的定
9、义,有( )处错误。 class MyClass public: void MyClass(); MyClass(int Value); private: int i=0; ;(分数:2.00)A.1B.2C.3D.416.下列关于构造函数的描述中,错误的是(分数:2.00)A.构造函数可以设置默认参数B.构造函数在定义类对象时自动执行C.构造函数可以是内联函数D.构造函数不可以重载17.如果表达式-x/y 中的“-”和“/”是作为友元函数重载的运算符,采用运算符函数调用格式,该表达式还可表示为(分数:2.00)A.operator/(operator-(),;B.operator/(oper
10、ator-(,;C.operator-().operator/(;D.operator/(operator-();18.在关系数据库中,用来表示实体之间联系的是(分数:2.00)A.树结构B.网结构C.线性表D.二维表19.语句 ofstream f(“DATA.DAT“,ios_base:app|ios_base:binary);的功能是建立流对象 f,并试图打开文件 DATA.DAT并与之连接,而且(分数:2.00)A.若文件存在,将文件指针定位于文件首;若文件不存在,建立一个新文件B.若文件存在,将其截为空文件,若文件不存在,打开失败C.若文件存在,将文件指针定位于文件尾;若文件不存在,
11、建立一个新文件D.若文件存在,打开失败;若文件不存在,建立一个新文件20.在面向对象的程序设计中,下列叙述中错误的是(分数:2.00)A.任何一个对象构成一个独立的模块B.一个对象不是独立存在的实体,各个对象之间有关联,相互依赖C.下一层次的对象可以继承上一层次对象的某些属性D.上述三种说法都正确21.执行语句: coutsetfill(*)setw(10)setfill(#)left123 “OK“end1;后将输出(分数:2.00)A.123*OKB.123#OKC.123*OK*D.123#OK#22.下列对模板的声明中正确的是(分数:2.00)A.templateTB.template
12、class T1,T2C.templateclass T1,class T2D.templateclass T1 ;class T223.软件需求分析阶段的工作,可以分为四个方面:需求获取,需求分析,编写需求规格说明书,以及(分数:2.00)A.阶段性报告B.需求评审C.总结D.都不正确24.对于语句 cin x;中的各个组成部分,下列叙述中错误的是(分数:2.00)A.“cin” 是一个输出流对象B.“;”的作用是表示语句结束C.“x”是一个变量D.“” 称作提取运算符25.下列对字符数组进行初始化的语句正确的是(分数:2.00)A.char a = “Hello“;B.char a = H
13、,e,l,l,o;C.char a5 = “Hello“;D.char a2 5 = “Hello“,“World“ ;26.算法的空间复杂度是指(分数:2.00)A.算法程序的长度B.算法程序中的指令条数C.算法程序所占的存储空间D.算法执行过程中所需要的存储空间27.下列叙述中正确的是(分数:2.00)A.在模块化程序设计中,一个模块应尽量多的包括与其他模块联系的信息B.在自顶向下、逐步细化的设计过程中,首先应设计解决问题的每一个细节C.在模块化程序设计中,一个模块内部的控制结构也要符合结构化原则D.在程序设计过程中,不能同时采用结构化程序设计方法与模块化程序设计方法28.有以下程序 #i
14、nclude iostream using namespace std; class R public: R(int r1,int r2) R1=r1; R2=r2; void print(); void print()const; private: iht R1,R2; ; void R:print() coutR1 “,“R2endl; void R:print() const coutR1 “,“R2endl; int main() R a(5,4); const R b(20,52); b.print(); return 0; 执行后的输出结果是 A) 5,4 B) 20,52 c)
15、0,0 D) 4,5(分数:2.00)A.B.C.D.29.有以下程序: #include iostream using namespace std; class A private: iht a; public: A(int i) a=i; void disp() couta“,“; class B private: int b; public: B(int j) b-j; void disp() coutb“,“; ; class C: public B,public A private: int c; public: C(int k):A(k-2),B(k+2) c=k; void di
16、sp() A:disp(); B:disp(); coutcendl; ,int main() C obj(l0); obj.disp(); return 0; 程序执行后的输出结果是(分数:2.00)A.10,10,10B.10,12,14C.8,10,12D.8,12,1030.下面有关重载函数的描述中正确的是(分数:2.00)A.重载函数必须具有不同的返回值类型B.重载函数形参个数必须不同C.重载函数必须具有不同的形参列表D.重载函数名可以不同31.下列语句段将输出字符*的个数为 int i=100; while(1) i-;; if(i=0) break; cout*; (分数:2.0
17、0)A.98个B.99个C.100个D.101个32.下列关于队列的叙述中正确的是(分数:2.00)A.在队列中只能插入数据B.在队列中只能删除数据C.队列是先进先出的线性表D.队列是先进后出的线性表33.重载输入流运算符必须使用的原型为(分数:2.00)A.ostream int x; void funA(int void funB(int,int int main() int first; int second=5; x=6; funA(first,second); funB(first,second); coutfirst“ “second“ “xendl; return 0; void
18、 funA(int first=a+b; a=2*b; b=first+4; void funB(int u,int second=x; v=second+4; x=u+v; (分数:2.00)填空项 1:_44.下面程序的运行结果是U 【9】 /U。 #include iostream using namespace std; class count static int n; public: count() n+; static int test() for(int i=0;i4;i+) n+; return n; ; int count:n = O; int main() coutcou
19、nt: test()“ “; count c1, c2; coutcount: test()endl; return 0; (分数:2.00)填空项 1:_45.以下程序运行后的输出结果是U 【10】 /U。 #include iostream #include string using namespace std; class Y; class X iht x; char *strx; public: X(int a,char *str) x=a; strx=new charstrlen(str)+1; strcpy(strx,str); void show(Y ; class Y priv
20、ate: iht y; char *stry; public: Y(int b,char *str) y=b; stry=new charstrlen(str)+ 1 ; strcpy(stry, str); friend void X:show(Y ; void X:show(Y coutob.stryendl; int main() X a(10,“stringX“); Y b(20,“stringY“); a.show(b); return 0; (分数:2.00)填空项 1:_46.在下面横线上填上适当的语句,完成程序。 #include iostream using namespac
21、e std; class Base int x; public: Base(int i) x=i; Base() ; class Derived: public Base public: _完成类 Derive 构造函数的定义 ; int main() Derived Obj; return 0; 在横线处应填入的语句是U 【11】 /U。(分数:2.00)填空项 1:_47.虚函数必须是类的U 【12】 /U。(分数:2.00)填空项 1:_48.U【13】 /U允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回值能取任意类型。(分数:2.00)填空项 1:_49.有以下程
22、序: #include iostream using namespace std; class Base public: Base() x=0; int x; ; class Derivedl: virtual public Base public: Derived1() x=10; ; class Derived2: virtual public Base public: Derived2() x=20; ; class Derived: public Derived1,protected Derived2 ; int main() Derived obj; coutobj.xendl; r
23、eturn 0; 该程序运行后的输出结果是U 【14】 /U。(分数:2.00)填空项 1:_50.下面是复数类 complex的定义,其中作为友元函数重载的运算符“-”的功能是将参数对象的实部减1,然后返回对该对象的引用;请补充完整。 class complex private: int real; iht imag; public: complex(int r=0,int i=0):real(r),imag(i) void show() coutreal(imag0?“-“ :“+“)imagi; U 【15】 /U; ; complex return c; (分数:2.00)填空项 1:
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 笔试 77 答案 解析 DOC
