《中山大学信息科学与技术学院计算机科学系C++程序设计A2014.06试卷》由会员分享,可在线阅读,更多相关《中山大学信息科学与技术学院计算机科学系C++程序设计A2014.06试卷(9页珍藏版)》请在金锄头文库上搜索。
1、1中山大学授予学士学位工作细则第六条考 试 作 弊 不 授 予 学 士 学 位计 算 机 科 学 系 2014 学 年 度 第 二 学 期 程 序 设 计 II 期 末 考 试 试 题 ( A )任 课 教 师 : 吴 维 刚 刘 聪 考 试 形 式 : 闭 卷 考 试 时 间 : 2 小 时年级: 班别: 专业: 姓名: _ 学号: _成绩1. Single Choice (20points)Please choose the choice that best completes the statement in the question1) Which of the following s
2、tatements about object-oriented programming (OOP) is NOT correct?A) The key idea of OOP is to build programs using software object.B) OOP offers many advantages: simplicity, modularity, modifiability, and so on.C) OOP is more efficient than POP in terms of programming productivity.D) An object-orien
3、ted program can run faster than a procedure-oriented program with the same functionality. 2) Which of the following statements about static data members is NOT correct?A) A static data member can initialized at declaration.B) A static data member refers to a member whose value cannot be changed afte
4、r initialized.C) We may access static data members without before any object created.D) A static data member is shared by objects of the same class. 3) Which of the following variables cannot be a member of class A? A) A *p B) A a C) A &r D) string s4) Which of the following statements is not a char
5、acteristic of a constructor?A) The name of a constructor must be the same as the class.B) A constructor can be overloaded.C) The parameters of constructor may have default values.D) The return type of a constructor must be void.5) If C is a class name, how many times is the constructor of C called i
6、n C a, b2, *p2;?A) 2 B) 3 C) 4 D) 56) If p is a pointer to an object with a member function x(), which of the following access to x() is correct?A) *p.x B) p-x() C) *p-x() D) *p.x() 警 示27) Which of the following is NOT a member function of a class?A) constructor B) destructor C) friend function D) c
7、opy constructor8) If class X is declared to be the friend of a class Y, then which of the following statements is correct? A) Y can access the protected members of X.B) X can access the private members of Y. C) If class Z is declared to be friend of X, Z becomes Ys friend.D) Y becomes Xs friend auto
8、matically9) Which of the following declarations of constant function member is correct?A) void print() const;B) const void print();C) void const print();D) void print(const);10) To realize polymorphism, the following two elements are necessary:A) Multiple-inheritance and virtual function B) Virtual
9、inheritance and function overloading C) Virtual function and pointer of base classD) Virtual inheritance and dynamic casting11) With the base class B and its derived D, which of the following statements has a compiling error? A) B * base = D(); B) B * base = new D(); C) B base = D(); D) B &base = D(
10、);12) Which of the following statements about virtual function is correct?A) Virtual function is not a member function.B) Virtual function must be a static function.C) A virtual function in a base class must be defined, even though it may not be used.D) A virtual function is function without impleme
11、ntation.13) Which of the following statements about upcast is NOT correct?A) Upcast is to cast a pointer of a base class to that of an derived class.B) C+ performs type checking for pointer to prevent errors.C) Upcast is always safe since an object of a derived class has everything of its base class
12、.D) Upcast does not have to be explicit.14) Which of the following definitions about pure virtual function is correct?A) virtual void fun()=0;B) void fun(int)=0;C) virtual void fun(int);D) virtual void fun(int)315) Which of the following statements about the operator new is NOT correct?A) The new op
13、erator is used to allocate storage dynamically.B) The new operator returns a object or a simple variable. C) The delete operator should be used to destroy the variable/object created by new.D) The new operator is necessary to realize deep copy.16) Which of the following statements about constructor
14、is correct?A) the constructor of a base class is executed after the constructor of a derived classB) the constructor of a base class cannot have any parameter.C) the constructor of a base class can be used to create an object of a derived classD) the constructor of a base class need to be called exp
15、licitly.17) An exception thrown by a function can beA) caught by only the catch block of the same functionB) handled exactly onceC) can only be an object of the exception classes defined by C+ standardD) a variable defined by the user18) With string s1; char s220; cins2;, which statement is NOT correct? A) s1 = s1+s2; B) s1.append(s2); C) s1 = s2; D) s2 = s1; 19) Which is NOT an I/O object?A) std:cin B) std:cout C) std: cerr D) iostream20) To output data into a file, it is necessary for you toA) make sure the file is already there before opening it.B) open it in binary mode.C) know