计算机二级C++考试技巧整理试题及答案
姓名:____________________
一、单项选择题(每题2分,共10题)
1.以下哪个选项是C++中的基本数据类型?
A.String
B.Float
C.Char
D.Boolean
2.在C++中,如何定义一个整型变量?
A.inta=10;
B.Integera=10;
C.Vara=10;
D.Dima=10;
3.以下哪个函数用于检查一个字符是否为数字?
A.isdigit()
B.isalpha()
C.isalnum()
D.islower()
4.以下哪个操作符用于取模运算?
A.%
B./
C.*
D.+
5.在C++中,如何定义一个指向整型的指针变量?
A.int*ptr;
B.intptr;
C.intptr;
D.intptr[];
6.以下哪个函数用于将字符串转换为整数?
A.atoi()
B.atof()
C.toint()
D.todouble()
7.在C++中,如何声明一个二维数组?
A.intarr[3][4];
B.intarr[3,4];
C.intarr[][4]={1,2,3,4,5,6,7,8};
D.intarr[3][4]={{1,2,3,4},{5,6,7,8}};
8.以下哪个关键字用于实现多态?
A.Class
B.Interface
C.Override
D.Virtual
9.在C++中,如何定义一个函数,该函数没有返回值?
A.voidfun();
B.fun();
C.intfun();
D.intfun(){};
10.以下哪个关键字用于表示类的私有成员?
A.Private
B.Public
C.Protected
D.Default
二、多项选择题(每题3分,共10题)
1.以下哪些是C++中的控制语句?
A.If
B.For
C.While
D.Switch
E.Do-While
2.在C++中,如何定义一个结构体?
A.structStudent{
charname[50];
intage;
};
B.structStudentname,age;
C.structStudentname,{
charname[50];
intage;
};
D.structStudent{
charname[50];
intage;
}student;
3.以下哪些是C++中的运算符?
A.+(加法)
B.-(减法)
C.*(乘法)
D./(除法)
E.%(取模)
F.(左移)
G.(右移)
H.==(等于)
I.!=(不等于)
J.(逻辑与)
4.在C++中,如何实现函数重载?
A.通过函数名相同,参数列表不同
B.通过函数名不同,参数列表相同
C.通过函数返回类型不同
D.通过函数参数类型不同
E.通过函数参数个数不同
5.以下哪些是C++中的标准库?
A.iostream
B.vector
C.string
D.algorithm
E.cmath
6.在C++中,如何定义一个模板函数?
A.templatetypenameT
B.templateclassT
C.templatetypenameT,typenameU
D.templateclassT,classU
7.以下哪些是C++中的异常处理关键字?
A.try
B.catch
C.throw
D.finally
E.continue
8.在C++中,如何定义一个指针数组?
A.int*pointers[10];
B.intpointers[10][10];
C.intpointers[10];
D.int(*pointers)[10];
9.以下哪些是C++中的继承方式?
A.Public
B.Protected
C.Private
D.Virtual
E.Abstract
10.在C++中,如何定义一个接口?
A.usingInterface;
B.classInterface;
C.structInterface;
D.templatetypenameTclassInterface;
三、判断题(每题2分,共10题)
1.在C++中,类的构造函数和析构函数必须和类名完全相同。()
2.在C++中,默认情况下,类的成员变量是私有的。()
3.C++中的虚函数只能在派生类中定