0
点赞
收藏
分享

微信扫一扫

【渝粤教育】国家开放大学2018年春季 7405-22T面向对象程序设计(本) 参考试题

科目编号:7405 座位号
2018-2019学年度第二学期期末考试
面向对象程序设计(本) 试题
2018年 7 月

一、单选题(本大题共10小题,每小题3分,共计30分)
(★请考生务必将答案填入到下面对应序号的答题框中★)

1.下面的函数声明中,哪一个是 “void BC(int a int b); ”的重载函数?
A int BC(int a, int b)
B void BC(int a, char b)
C float BC(int a,int b, int c=0)
D void BC(int a, int b= 0)
2.设 x 和 y均为bool量,则x || y 为假的条件是
A 它们均为真
B 其中一个为真
C 它们均为假
D 其中一个为假
3.假定一个二维数组的定义语句为“int a[3][4]={{3,4},{2,8,6}};”,则元素a[2][l]的值为()。
A. 0
B.4
C.8
D.6
4.假定AA是一个类,abc()是该类的一个成员函数,则参数表中隐含的第一个参数的标识符为()。
A.abc
B.int
C.this
D.bool
5.对于任一个类,用户所能定义的析构函数的个数至多为()。
A.0
B.1
C.2
D.任意个
6.在关键字public后面定义的成员为该类的()成员。
A.私有
B.公用
C.保护
D.任何
7.程序中主函数的名字为(),
A.main
B.MAIN
C.Main
D.任意标识符
8.用来构成C++程序文件的基本单位是()
A.字符 B.语句 C.函数 D.表达式
9.假定p是具有int类型的指针变量,则给P赋值的正确语句为()。
A. p=new int
B.p=aew int*
C. p=new int

D.p=new int[10]
10.当处理特定问题的循环次数已知时,通常采用()来解决。
A. for循环
B.while循环
C.do循环
D.switch语句

二、填空题(本大题共5小题,每小题4分,共计20分)
(★请考生务必将答案填入到下面对应序号的答题框中★)

1.假定x=5,y=6,则表达式x- -*–y的值为
2.存储字符串"a"需要占用_______个字节
3.在一个用数组实现的队列类中,假定数组长度为MS,队首元素位置为first,队列长度
为length,则队列为满的条件是_______。
4.若在类的定义体中只给出了一个成员函数的原型,则在类外给出完整定义时,其函数名前必须加上 和两个冒号分隔符。
5.假定a是一个一维数组,则a[i]的指针访问方式为 。

三、程序阅读题(本大题共5小题,每小题6分,共计30分)

1.#include<iostream.h>
void main()
{
int x=5;
switch(2x-3){
case 4: cout<<x<<’’; break;
case 7: cout<<2
x+1<<’’;break;
case 10:cout<<3*x-1<<’’;break;
default:cout<<“default”<<endl;
}
}

请写出以上程序的运行结果:

2.#include<iostream.h>
#include<string.h>
void main()
{
int i,len=0;
char a[3][8]={“year”,“month”,“day”};
for(i=0;i<3;i++)
len+=strlen(a[i]);
cout<<len<<endl;
}

请写出上述程序的运行结果:

3.#include<iostream.h>
const int B=2;
void main()
{
int p=1,s=1;
while(s<50){
p*=B;
s+=p;
}
cout<<“s=”<<s<<endl;
}

请写出上述程序的运行结果:

4.#include<iostream.h>
class CE {
private:
int a,b;
int getmin(){
return (a<b?a:b);
}
public:
int c;
void SetValue(int x1,int x2,int x3){
a=x1;b=x2;c=x3;
}
int GetMin();
};

int CE::GetMin(){
int d=getmin();
return (d<c?d:c);
}

void main()
{
int x=5,y=12,z=8;
CE * ep=new CE;
ep->SetValue(x+y,y-z,10);
cout<GetMin()<<endl;
}

请写出上述程序的运行结果:

5.#include<iostream.h>
void main(){
int s1=0;
for(int i=1;i<=4;i++) s1+=2*i;
cout<<“s1=”<<s1<<endl;
}

请写出上述程序的运行结果:

四、程序分析题(本大题共2小题,每小题10分,共计20分)

1.int WC(int a[],int n,int k){
int c=0;
for(int i=0;i<n;i++)
if(a[i]>=k) c++;
return c;
}

请描述上述函数的功能:

2.int SC(int a,int b,int c){
if(a>b) a=b;
if(a>c) a=c;
return a;
}

请描述上述函数的功能:

举报

相关推荐

0 条评论