整专业资料
微信QQ群
考生网QQ群

群号:517231281

扫码加群
点击二维码加群

考生网微信公众号

微信号:zikaosw

课程试听
最新资讯

手机端访问

1、直接输入www.zikaosw.cn
2、扫描左侧二维码

登录 | 注册
登录/注册后,可享受
  • 课程免费试听
  • 试做在线题库
  • 学习提升指导
自考生网
当前位置 自学考试 > 自考历年真题 > 面向对象程序设计自考历年真题 > 文章详情

2006年1月02328面向对象程序设计历年真题及答案

来源:考生网小编 时间:2024-03-17 09:00:00 编辑:考生网编辑

自考生网为考生们整理提供了“2006年1月02328面向对象程序设计历年真题及答案”,更多02328面向对象程序设计真题内容可点击查看02328面向对象程序设计真题及答案汇总。

注:不同省份、不同专业的自考历年真题及答案,只要课程代码和课程名称相同,都可参考使用。

2006年1月02328面向对象程序设计历年真题及答案

1、面向对象程序设计中的数据隐藏指的是(   )

A.输入数据必须输入保密口令

B.数据经过加密处理

C.对象内部数据和代码合并在一起

D.对象内部数据结构的不可访问性

查看答案   模拟考场

2、要将类A说明是类B的虚基类,正确的描述是 (   )

A.class virtual B:public A

B.class B:virtual public A

C.virtual class B:public A

D.class B:public A virtual

查看答案   模拟考场

3、下面关于静态成员的描述中,正确的是 (   )

A.静态数据成员是类的所有对象共享的数据

B.类的每个对象都有自己的静态数据成员

C.类的不同对象有不同的静态数据成员值

D.静态数据成员不能通过类的对象访问

查看答案   模拟考场

4、假设Sample是个类,则语句“Sample a[2],*p[3];”调用构造函数的次数为(   )

A.0

B.2

C.3

D.5

查看答案   模拟考场

5、在面向对象的程序设计中,将一组对象的共同特性抽象出来形成________________。

查看答案   模拟考场

6、在C++中要创建一个文件输入流对象fin,同时该对象打开文件“Test.txt”用于输入,则正确的声明语句是________________。

查看答案   模拟考场

7、如果要把类B的成员函数void fun( )说明为类A的友元函数,则应在类A中加入语句________________。

查看答案   模拟考场

8、A是一个类,已有语句“A* p;p=new A[10];”。要释放由p指向的报考空间,正确的语句应该是________________。

查看答案   模拟考场

9、如果一个引用不是用作函数参数或返回值,则在说明该引用时必须对它进行________________。

查看答案   模拟考场

10、如果要把PI声明为值为3.14159类型为双精度实数的符号常量,该声明语句是________________。

查看答案   模拟考场

11、【改错题】下面的程序有一处错误,请用下横线标出错误所在行并说明错误原因。
#include
class Base
{
public:
virtual void fun( ){cout<<"Base function"<};
class Derived:public Base
{
public:
void fun( ){cout<<"Derived function"<};
void main( )
{
Base b;
Derived* p=&b;
B.fun( );
p->fun( );
}

查看答案   模拟考场

12、【改错题】下面的程序有一处错误,请用下横线标出错误所在行并说明错误原因。
#include
class A
{
int x;
protected:
int y;
public:
A(int xx,int yy){x=xx; y=yy;}
};
class B:public A
{
public:
B(int a,int b):A(a,b){}
void display( ){cout<};
void main( )
{
B b(5,10);
B.display( );
}

查看答案   模拟考场

13、【完成程序题】请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:
2,1
4,3
#include
class A
{
int a;
public:
A(int i=0){a=i;}
int Geta( ){return a;}
};
class B
{
A a;
int b;
public:
B(int i=0,int j=0): ①        {}
void display( ){cout<};
void main( )
{
B b[2]={B(1,2),B(3,4)};
for(int i=0;i<2;i++)
②        ;
}

查看答案   模拟考场

14、【完成程序题】下面程序中A是抽象类。请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:
B1 called
B2 called
#include
class A
{
public:
①            ;
};
class B1:public A
{
public:
void display( ){cout<<”B1 called”<};
class B2:public A
{
public:
void display( ){cout<<”B2 called”<};
void show(②        )
{
p->display( );
}
void main( )
{
B1 b1;
B2 b2;
A* p[2]={&b1,&b2};
for(int i=0;i<2;i++)
show(p[i]);
}

查看答案   模拟考场

15、【完成程序题】请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:
Name:王小明
Grade:90
#include
#include
class Person
{
char name[20];
public:
Person(char* s){strcpy(name,s);}
void display( ){cout<<”Name:”<};
class Student:public Person
{
int grade;
public:
Student(char* s, int g): ①        {grade=g;}
void display( )
{
②        ;
cout<<”Grade:”<}
};
void main( )
{
Student s(“王小明”,90);
s.display( );
}

查看答案   模拟考场

16、【完成程序题】请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为5。
#include
class Integer
{
int x;
public:
Integer(int a=0){x=a;}
void display( ){cout<____①_____             ;
};
Integer Max(Integer a,Integer b)
{
if(_______②____ )
return a;
return b;
}
void main( )
{
Integer a(3),b(5),c;
c=Max(a,b);
C.display( );
}

查看答案   模拟考场

17、【完成程序题】请在下面的横线处填上适当内容,以使类的定义完整。
class Array
{
int* ptr;
int size;
public:
Array( ){size=0; ptr=0;}
Array(int n){size=n;ptr=new int[size];}
Array(______①_______ )    //复制初始化构造函数
{
size=A.size;
ptr=new int[size];
for(int i=0;i_____②_____ ;    //将源对象的报考数组内容复制到目标对象
}
};

查看答案   模拟考场

18、【程序分析题】阅读下面的程序,写出程序运行的结果。

查看答案   模拟考场

19、【程序分析题】阅读下面的程序,写出程序运行的结果。

查看答案   模拟考场

更多本套试题及答案 >> 点此查看

温馨提示:本网站所提供的考试信息仅供考生参考,考试政策请以权威部门公布的正式信息为准。
更多优惠课程课程推荐
资料套餐 关闭