第一章 单元测试
1、 下列哪个不是面向对象技术的特点( )
A:封装
B:逻辑
C:多态
D:抽象
答案:
逻辑
2、 C++中关于class和struct的说法正确的是( )
A:二者没有区别
B:二者默认成员都公有的
C:二者默认成员都私有的
D:struct的成员默认是公有的,而类的成员默认是私有的
答案:
struct的成员默认是公有的,而类的成员默认是私有的
3、 有以下类的定义:
class Ex{
int x;
public:
void setx(int t=0);
};
若在类外定义成员函数setx(),以下定义形式中正确的是( )
A:void setx(int t) { … }
B:void Ex::setx(int t) { … }
C:Ex::void setx(int t) { … }
D:void Ex::setx(){ … }
答案:
void Ex::setx(int t) { … }
4、 #include<stdio>
class Test {
int x;
};
int main()
{
Test t;
printf(“%d”, t.x);
return 0;
}
以上代码运行结果是( )
A:0
B:x
C:任意数值
D:编译错误
答案:
编译错误
5、 类就是c语言中的结构类型。( )
A:对
B:错
答案:
错
6、 A member function can always access the data in ( )
A:the class of which it is member
B:the object of which it is a member
C:the public part of its class
D:the private part of its class
答案:
the class of which it is member
7、 What does your class can hold? ( )
A:Data
B:Functions
C:Both a & b
D:None of the mentioned
答案:
Both a & b
8、 What purpose do classes serve? ( )
A:data encapsulation
B:providing a convenient way of modeling real-world objects
C:simplifying code reuse
D:all of the above
答案:
all of the above
9、 Which of the following is a valid class declaration? ( )
A:class A { int x; };
B:class B { }
C:public class A { }
D:object A { int x; };
答案:
class A { int x; };
10、 OOP stands for ( )
A:Object to Object Programming
B:Object Oriented Programming
C:Online Objects Programming
D:Object Oriented Processes
答案:
Object Oriented Programming
第二章 单元测试
1、 有关函数重载的正确说法是 ( )
A:函数名不同,但参数的个数和类型相同
B:函数名相同,但参数的个数不同或参数的类型不同
C:函数名相同,参数的个数和类型相同
D:函数名相同,函数的返回值不同,而与函数的参数和类型无关
答案:
函数名相同,但参数的个数不同或参数的类型不同
2、 使用运算符 . 可以访问名字空间里的函数。( )
A:对
B:错
答案:
错
3、 作用域运算符“::”的功能是 ( )
A:标识作用域的级别的
B:指出作用域的范围的
C:给定作用域的大小的
D:标识成员是属于哪个类或哪个命名空间
答案:
指出作用域的范围的
4、 适宜采用inline定义函数情况是 ( )
A:函数体含有循环语句
B:函数体含有递归语句
C:函数代码少、频繁调用
D:函数代码多、不常调用
答案:
函数代码少、频繁调用
5、 类A有如下成员函数:
int A::fun(double x){return (int) x/2;}
int A::fun(int x){return x*2;}
设a为类A的对象,在主函数中执行语句int s = a.fun(6) + a.fun(2.0)后的s值 ( )
A:13
B:4
C:5
D:7
答案:
13
6、 Which of the following is a valid inline for function foo? ( )
A:inline void foo() {}
B:void foo() inline {}
C:inline:void foo() {}
D:None of the above
答案:
inline void foo() {}
7、 #include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z)
{
return (x + y + z);
}
int main()
{
printf(“%d”, fun(10));
return 0;
}
Output? ( )
A:10
B:0
C:20
D:Compiler Error
答案:
Compiler Error
8、 #include <iostream>
using namespace std;
int fun(int=0, int = 0)
{
return (x+y);
}
int main()
{
printf(“%d”, fun(5));
return 0;
}
Output? ( )
A:Compiler Error
B:5
C:0
D:10
答案:
5
9、 Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++. ( )
A:Inheritance
B:Polymorphism
C:Encapsulation
D:None of the above
答案:
Polymorphism
10、 #include <iostream>
using namespace std;
namespace T{
class A {
public:
void show() {
printf(“Go”);
}
};
}
int main(){
T::A obj;
obj.show();
return 0;
}
Output? ( )
A:0
B:Go
C:No output
D:Compilation Error
答案:
Go
第三章 单元测试
1、 引用就是变量的别名,声明引用时必须同时对它初始化。( )
A:对
B:错
答案:
对
点击这里,查看后续答案①
点击这里,查看后续答案②(阿布查查更好用)
点击下方链接,查看更多网课答案目录
①知到智慧树答案目录
②超星尔雅学习通答案满分2026年版目录
③中国大学mooc慕课答案满分2026年版目录
#()A对B错 ##includeclassTest{intx;};intmain(){Testt;printf(“%d”,t.x);return;}以上代码运行结果是()ABxC任意数值D编译错误 ##includeusingnamespacestd;intfun(int=,int=){return(x+y);}intmain(){printf(“%d”,fun());return;}Output?()ACompilerErrorBCD ##includeusingnamespacestd;intfun(intx=,inty=,intz){return(x+y+z);}intmain(){printf(“%d”,fun());return;}Output?()ABCDCompilerError ##includeusingnamespacestd;namespaceT{classA{publicvoidshow(){printf(“Go”);}};}intmain(){TAobj;obj.show();return;}Output?()ABGoCNooutputDCompilationError #①点击这里,查看后续 #②(阿布查查更好用)点击下方链接,查看更多网课 #Alloftheabove. #Amemberfunctioncanalwaysaccessthedatain()AtheclassofwhichitismemberBtheobjectofwhichitisamemberCthepublicpartofitsclassDtheprivatepartofitsclass #Botha&b #C++中关于class和struct的说法正确的是()A二者没有区别B二者默认成员都公有的C二者默认成员都私有的Dstruct的成员默认是公有的,而类的成员默认是私有的 #classA{intx;}; #CompilerError #Go第三章单元测试 #inlinevoidfoo(){} #ObjectOrientedProgramming第二章单元测试 #OOPstandsfor()AObjecttoObjectProgrammingBObjectOrientedProgrammingCOnlineObjectsProgrammingDObjectOrientedProcesses #Polymorphism #struct的成员默认是公有的,而类的成员默认是私有的 #theclassofwhichitismember #voidExsetx(intt){…} #Whatdoesyourclasscanhold?()ADataBFunctionsCBotha&bDNoneofthementioned #Whatpurposedoclassesserve?()AdataencapsulationBprovidingaconvenientwayofmodelingrealworldobjectsCsimplifyingcodereuseDalloftheabove #WhichofthefollowinginObjectOrientedProgrammingissupportedbyFunctionoverloadinganddefaultargumentsfeaturesofC++.()AInheritanceBPolymorphismCEncapsulationDNoneoftheabove #Whichofthefollowingisavalidclassdeclaration?()AclassA{intx;};BclassB{}CpublicclassA{}DobjectA{intx;}; #Whichofthefollowingisavalidinlineforfunctionfoo?()Ainlinevoidfoo(){}Bvoidfoo()inline{}Cinlinevoidfoo(){}DNoneoftheabove #下列哪个不是面向对象技术的特点()A封装B逻辑C多态D抽象 #不常调用 #作用域运算符“”的功能是()A标识作用域的级别的B指出作用域的范围的C给定作用域的大小的D标识成员是属于哪个类或哪个命名空间 #使用运算符.可以访问名字空间里的函数 #函数代码少 #函数名相同,但参数的个数不同或参数的类型不同 #对点击这里,查看后续 #引用就是变量的别名,声明引用时必须同时对它初始化 #指出作用域的范围的 #智慧树答案 #智慧树答案APP #智慧树答案全套免费 #智慧树答案公众号免费 #智慧树答案大全-知到智慧树题库 #智慧树答案知到答案-网课答案题库大全 #智慧树见面课答案 #有以下类的定义:classEx{intx;publicvoidsetx(intt=);};若在类外定义成员函数setx(),以下定义形式中正确的是()Avoidsetx(intt){…}BvoidExsetx(intt){…}CExvoidsetx(intt){…}DvoidExsetx(){…} #有关函数重载的正确说法是()A函数名不同,但参数的个数和类型相同B函数名相同,但参数的个数不同或参数的类型不同C函数名相同,参数的个数和类型相同D函数名相同,函数的返回值不同,而与函数的参数和类型无关 #满分年版目录 #满分年版目录③中国大学mooc慕课 #目录①知到智慧树 #目录②超星尔雅学习通 #知到智慧树答案 #知到答案 #第一章单元测试 #类A有如下成员函数:intAfun(doublex){return(int)x/;}intAfun(intx){returnx*;}设a为类A的对象,在主函数中执行语句ints=a.fun()+a.fun(.)后的s值()ABCD #类就是c语言中的结构类型 #编译错误 #网课答案 #适宜采用inline定义函数情况是()A函数体含有循环语句B函数体含有递归语句C函数代码少 #逻辑 #错 #面向对象程序设计(C++)(北方工业大学)智慧树章节测试答案 #面向对象程序设计(C++)(北方工业大学)知到智慧树答案满分2026年版 #面向对象程序设计(C++)(北方工业大学)知到答案 #频繁调用 #频繁调用D函数代码多