300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 计算机国二笔试试题 全国计算机等级考试二级笔试试卷

计算机国二笔试试题 全国计算机等级考试二级笔试试卷

时间:2021-12-25 07:53:23

相关推荐

计算机国二笔试试题 全国计算机等级考试二级笔试试卷

全国计算机等级考试二级笔试试卷

A)5 B)4 C)3 D)2

(25)在公有派生的情况下,派生类中定义的成员函数只能访问原基类的

A)公有成员和私有成员 B)私有成员和保护成员

C)公有成员和保护成员 D)私有成员、保护成员和公有成员

(26)在C++中用来实现运行时多态性的是

A)重载函数 B)析构函数

C)构造函数 D)虚函数

(27)一个类可以同时继承多个类,称为多继承。下列关于多继承和虚基类的表述中,错误的是

A)每个派生类的构造函数都要为虚基类构造函数提供实参

B)多继承时有可能出现对基类成员访问的二义性问题

C)使用虚基类可以解决二义性问题并实现运行时的多态性

D)建立最派生类对象时,虚基类的构造函数会首先被调用

(28)在一个类体的下列声明中,正确的纯虚函数声明是

A) virtual void vf()=0; B) void vf(int)=0;

C) virtual int vf(int); D) virtual void vf(int) { }

(29)在下面的运算符重载函数的原型中,错误的是

A) Volume operator - (double, double);

B) double Volume::operator- (double);

C) Volume Volume: :operator - (Volume);

D) Volume operator - (Volume, Volume);

(30)下列是模板声明的开始部分,其中正确的是

A) template

B) template

C) template

D) template

(31)执行语句序列

ofstream outfile("DATA.DAT");

if(...) cout << "OK"; else cout << "FAIL";

后,如果文件打开成功显示“OK”,否则就显示“F厶n。”。由此可知,上面if语句的...

处的表达式应是

A )outfile.fail() 或 outfile B )outfile.good() 或 !outfile

C )outfile.good() 或 outfile D )outfile.fail() 或 !outfile

(32)C++流中重载的运算符>>是一个( )

A)用于输出操作的.非成员函数 B)用于输入操作的非成员函数

C)用于输出操作的成员函数 D)用于输入操作的成员函数

(33)有以下类定义

class Point {

public:

Point(int x = 0, int y = 0) { _.x = x; _.y = y; }

void Move(int xOff, int yOff)

{ _x += xOff; _.y += yOff; }

void Print() const

{ cout << '(' << _x << ',' << _y << ')' << endl; }

private:

int _x, _y;

};

下列语句中会发生编译错误的是

A) Point pt; pt.Print();

B) const Point pt; pt.Print();

C) Point pt; pt.Move(l, 2);

D) const Point pt; pt.Move(l, 2);

(34)有以下类定义

class MyClass

{

private:

int id;

char gender,

char *phone;

public:

MyClass():id(0),gender('#'),phone(NULL) { }

MyClass(int no, char ge='#', char *ph= NULl.)

{ id=no;gende=ge;phone=ph; }

};

下列类对象定义语句中错误的是

A) MyClass myObj;

B) MyClass myObj(11, "13301111155");

C) MyClass myObj(12, 'm');

D) MyClass myObj(12);

(35)有以下程序

#include

using namespace std;

class Complex

{

public:

Complex(double r =0, double i =0):re(r), im(i) { }

double real() const { return re; }

double imag() const { return im;}

Complex operator +(Complex c) const

{ return Complex(re+c.re, im+c.im); }

private:

double re, im;

};

int main()

{

Complex a = Complex(l, 1) + Complex(5);

cout << a.real() << '+' << a.imag() <

return 0;

}

程序执行后的输出结果是

A) 6+6i B) 6+1i C) 1+6i D) 1+1i

二、填空题(每空2分,共30分)

请将每一个空的正确答案写在答题卡[1]-[15]序号的横线上,答在试卷上不得分。注意:以命令关键字填空的必须拼写完整。

(1)算法的复杂度主要包括 [1] 复杂度和空间复杂度。

(2)数据的逻辑结构在计算机存储空间中的存放形式称为数据的 [2] 。

(3)若按功能划分,软件测试的方法通常分为白盒测试方法和 [3] 测试方法。

(4)如果一个工人可管理多个设备,而一个设备只被一个工人管理,则实体“工人”与实体“设备”之间存在 [4] 的联系。

(5)关系数据库管理系统能实现的专门关系运算包括选择、连接和 [5] 。

(6)设有定义语句:int a=12;,则表达式a*=2+3的运算结果是 [6] 。

(7)从实现的角度划分,C++所支持的两种多态性分别是 [7] 时的多态性和运行时的多态性。

(8)将—个函数声明为一个类的友元函数必须使用关键字 [8] 。

(9)请按下面注释的提示,将类B的构造函数定义补充完整。

class A

{

int a;

public:

A(int aa=0) { a=aa; }

};

class B: public A {

int b;

A c;

public:

//用aa初始化基类A,用aa+1初始化类对象成员c

B(int aa): [ 9 ] { b=aa+2; }

};

(10)下列程序的输出结果是 [10] 。

#include

using namespace std;

int main()

{

int i = 5;

int &r = i; r = 7;

cout << i << endl;

return 0;

}

(11)下列程序的输出结果是 [11] 。

#include

using namespace std;

class Test {

public:

Test() { cnt++; }

~Test() {cnt--; }

static int Count() { return cnt;}

private:

static int cnt;

};

int Test::cnt = 0;

int main()

{

cout << Test::Count0 <

Test tl, t2;

Test* pT3 = new Test;

Test* pT4 = new Test;

cout << Test::Count0 <

delete pT4;

delete pT3;

cout << Test::Count() << endl;

return 0;

}

(12)下面是用来计算n的阶乘的递归函数,请将该函数的定义补充完整。(注:阶乘的定义是n!=n*(n-1)*...*2*1)

unsigned fact(unsigned n)

{

if ( n<= 1)

return 1;

return [ 12 ] ;

}

(13)下列程序的输出结果是 [13] 。

#include

using namespace std;

template

T fun(T a, T b) { return (a<=b)?:b;}

int main()

{

cout << fun(3, 6) << ',' << fun (3.14F, 6.28F) << endl;

return 0;

}

(14)与成员访问表达式p->name等价的表达式是 [14] 。

(15)下列程序的输出结果是 [15] 。

#include

using namespace std;

class base {

public:

int n;

base(int x) { n = x;}

virtual void set(int m) { n = m; cout << n <

};

class deriveA:public base {

public:

deriveA(int x):base(x) { }

void set(mt m) { n += m; cout << n <

};

class deriveB:public base [

public:

deriveB(int x):base(x) { }

void set(int m) { n +=m; cout <

};

int main()

{

deriveA dl(1);

deriveB d2(3);

base *pbase;

pbase = &dl;

pbase->aet(1);

pbase = &d2;

pbase->set(2);

return 0;

}

9月

全国计算机等级考试二级笔试试卷

公共基础知识及C++语言程序设计

答案及评分标准

选择题((1)—(35)每小题2分,共70分)

(1) C (2) C (3) B (4) A (5) D

(6) B (7) D (8) B (9) C (10)A

(11)D (12)D (13)C (14)D (15)A

(16)A (17)D (18)B (19)D (20)C

(21)B (22)A (23)B (24)B (25)C

(26)D (27)C (28)A (29)A (30)C

(31)C (32)B (33)D (34)B (35)B

二、填空题(每空2分,共30分)

(1)[1] 时间

(2)[2] 存储结构 或 物理结构 或 物理存储结构

(3)[3] 黑盒 或 黑箱

(4)[4] 一对多 或 1对多 或 I:M 或 I:N(其中M、N大小写均可)

(5)[5] 投影

(6)[6] 60

(7)[7] 编译

(8)[8] friend

(9)[9] A(aa),c(aa+1) 或 c(aa+1),A(aa)

(10)[10] 7

(11)[11] 042

(12)[12] n*fact(n-1)

(13)[13] 3,3.14

(14)[14] (*p).name

(15)[15] 25

相关文档推荐:

3月全国计算机二级C++考试真题与答案

计算机全部等级考试

9月计算机等级考试二级C++

9月二级C++笔试

3月计算机等级考试二级C++笔试

9月全国计算机二级C++笔试

9月二级C++笔试

3月全国计算机等级考试二级C++

【全国计算机等级考试二级笔试试卷】相关文章:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。