面向对象程序设计(C++)(北方工业大学)知到智慧树答案满分2026年版

第一章 单元测试

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年版目录