面向对象程序设计计科05c答案_第1页
面向对象程序设计计科05c答案_第2页
面向对象程序设计计科05c答案_第3页
面向对象程序设计计科05c答案_第4页
面向对象程序设计计科05c答案_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、。装。订。线。2006 年2007 年第 1 学期 计科 04面象程序设计 试卷 C 卷时间共 120 分钟一、填空题(每题 2 分,共 10 分)填空题1、写出一个 C+的逻辑语句,如果 testScroe 的值大于或是等于 100,并且小于等于 200,则其取值为 true:(testScroe=100 &testScroe )。)控制结构。2、3、4、使得某序列语句重复执行的控制结构称为(循环在一个类中把另外一个类的一个对象定义为数据成员,这种机制称为( 组合)。给出如下函数,表达式 Func(2)的值是(14)。Func( /* in */if (n != 5)n ) return 3

2、 + Func(n + 1);elsereturn 5;5、在面象程序设计中,所谓的消息传递是指( 函数调用)。二、判断题。把正确选项填入下面的表格的中,正确的标,错误的标。(每题 2 分,共 20 分)F There is only one unique general solution (algorithm) for a given problem. c1T A programming language is said to be (case sensitive) if it considers uppercase letters to be different from lowercas

3、e letters.T If a C+ If sement begins with if (age = 30), the If condition is an assignment expres, not a relational1、2、3、expres.4、5、F An infinioop is one in which the While expresalways has the value false.T The code segmentcout response;while (response != Y & response != N) cout response;is equival

4、ent to the following code segment. docout response; while (response != Y & response != N);6、 F In C+, the express beta+ and +beta cways be usederchangeably.7、 F A C+ class can have at most one constructor.8、 F In C+, two different classes-say, MyClass and YourClass-cannot both have member functions

5、named Subtract.题号12345678910111213得分阅卷人得分阅卷人题号12345678910总分得分阅卷人9、 T The components of an array are all of the same daype.10、F A sequential search on a sorted list cannot be made quickern one on an unsorted list.11、F An inheritance hierarchy gives a visual picture of has-a relationships.12、F In C+,

6、a derived classs constructor is executed before its base class constructor is executed.13、F Given the following recursive formula, the value of F(3) is 11.F(N) = 2 + F(N - 1), if N 1and F(N) = 5, if N = 1三、选择题。把正确选项填入下面的表格的中。(每题 3 分,共 54 分)、 B Which of the following translates a program written in a

7、 high-level language code?o machineA. a mouseB. a compilerC. an operating systemD. an editor2、 CWhich of the following terms describes the repetition of sements (instructions) while certain conditions are met?A. sequenceB. selectionC. looD. subprogram3、 B Which of the following is a legal string ass

8、ignment?A. name = Jones;B. name = Jones;C. name = 123 + Jones;D. b and c above4、 B Givent x is a float variable and num is anvariable containing the value 5, what will x contain afterexecution of the following sement:x = num + 2;A. 7B. 7.0C. 5D. 5.0E. nothing; a compile-time error occurs5、 A Which o

9、f the following sements abo+ stream input is true?When anfloating-poWhen aneger data value is read form.eger data value is reado a float variable, the value isconvertedoo a float variable, the float variablees anvariable.C. It is an error to read aneger data valueo a float variable.D. Input of a flo

10、ating-poE. c and d abovedata value stops when a decimal pois encountered.6、 E After execution of the following code, what will be the value o cin angle;if (angle 5)angle = angle + 5; if (angle 2)angle = angle + 10;le if the input value is 10?A. 0B. 5C. 10D. 15E. 257、 D What is the value of loopCount

11、 after control exits the following loop? loopCount = 1;while (loopCount = 145) alpha = alpha + 7; loopCount+;A. 1B. 144C. 145D. 1468、 D Given the function headingvoid GetNums(howMany,float& alpha,float& beta)which of the following is a valid function prototype fetNums?A. void GetNums(howMany, float&

12、 alpha, float& beta );B. void GetNums(, float&, float& );C.GetNums(, float&, float& );D. a and b aboveE. a, b, and c above题号12345678910111213得分阅卷人9、 C What is the output of the following code fragment? (beta is of type beta = 5;doswitch (beta)case 1 : cout R;break;case 2 :case 4 : cout O;break; case

13、 5 : cout 1); cout X;.)A. XB. ROOLXC. LOOXD. LOORXE. ROOX10、25.B What is the output of the following code fragment?string msg = HELP; cout msg2;A. EB. LC. HED. HELPHELPE. none of the above11、A Given the class declaration class MyClasspublic:.void Func(); private:n;what noion does the body of Func us

14、e to assign the value 3 to n?A. n = 3;B. MyCla= 3;C. MyClass:n = 3;D. someObject.n = 3;E. It cant be done-n is private.12、E A class SomeClass has a member function Fs no parameter list, returns anvalue, correctand does not modify any of the private data.Which of the following would be the function d

15、efinition for F?F() const .A.B. constF() .C. SomeClass:F() const .D. constSomeClass:F() .E.SomeClass:F() const .13、22.D Given the declarationlistVals7 = 10, 15, 20, 25, 30, 35, 40;a binary search is used to search the list for the value 35. In each iteration of the search loop, the index variablesmi

16、ddle, and last define the range of items being searched. When the search is finished, what is the value of,?(RememberA. 0t C+ arrays begin at index 0.)B. 2C. 3D. 4E. 514、20.D Consider the following C+ class declarations: class Xpublic:void Func1(); void Func2();private:m;class Y : public X public:vo

17、id Func3(); private:float f;How many public members does class Y have?A.0B.1C.2D.3E.415、24.B Supet class X has a class membert is an object of another class Y. If classes X and Y bothhave constructors, in what order will the constructors be executed when an object of class X is created?A.Xs construc

18、tor is executed, then Ys.B.Ys constructor is executed, then Xs.C.Both constructors are executed at the same time.E.Only Ys constructor is executed.D.Only Xs constructor is executed.16、27.A Supet a C+ class D is derived from a base class B. Class B has a public member function Func()t is not declared

19、 to be virtual, and class D reimplements Func(). At execution time, supe passed to the following function:void DoSomething( B& x ) x.Func();t a D object isWithhe DoSomething function, whose verof Func() is called?and b aboveA.Bs ver17、B In theB.Ds verC.boD.neither a nor b aboveobject-oriented design of an airline passenger reservation program, supet airplane seat,aisle seat, and window seat have been identified as objects. Focusing specifically on the aisle seat object,how does it relate to the airplaa

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论