2nd SEMESTER 2021/22 Resit Exam
Undergraduate – Year 2
C++ Programming and Software Engineering II
Exam Duration: 2 Hours
INSTRUCTIONS TO CANDIDATES
1、 This is an open book resit exam. Please complete the exam independently and honestly.
2、 The total marks available are 100.
3、 Answer all questions in the answer booklet and submit it to LMO. There is NO penalty for providing a wrong answer.
4、 The duration is 2 hours.
Q1 | Multiple choice. Select the correct option. | Total 30 | |
a) | Which of the following statements is NOT correct? a. Low coupling often correlates with high cohesion. b. Coupling is a measure of the amount of interaction between modules. c. Cohesion is a measure of the amount of interaction between action and information within a module. d. High coupling is much better than high cohesion. | (2) | |
b) | The most restrictive the access modifiers are:
a. Private. b. Protected c. Public. d. None of above | (2) | |
c) | There is a pointer double *a. Which of the following is a possible correct output for the statement cout<<sizeof(a)?
a. 16 b. 2 c. 4 d. 12 | (2) | |
d) | Assuming that t is an array and p is a pointer to that array, which expression does not refer to the value of element 3 of the array?
a. *(p + 3) b. p[3] c. &t[3] d. *(t + 3) | (2) | |
e) | The has-a relationship represents.
a. Composition. b. Inheritance. c. Information Hiding. d. Aggregation. | (2) |
f) | Variables defined inside a class but outside a function have:
a. File scope. b. Class scope. c. Block scope. d. Class or block scope, depending on whether the binary scope resolution operator (::) is used. | (2) | |
g) | Files ending in .cpp are known as files.
a. Executable b. Binary c. Source-code d. Header | (2) | |
h) | Which of the following is not a correct way to initialize an array?
a. int n[5]{7, 0, 3, 8, 2}; b. float n[]{7, 0, 3, 8, 2}; c. char n[]{“7”, “a”}; d. double n[5]{1, 2}; | (2) | |
i) | Given the class definition:
class Myclass{ public: Myclass () {} Myclass (int n) {cout << "constructor called, ";} ~ Myclass () {cout << "destructor called, ";} }; What will the following program output?
int main(){ MyClass c1(1); MyClass c2; MyClass *p; return 0; } a. constructor called, destructor called, constructor called, destructor called, b. constructor called, destructor called, destructor called, | (2) |
c. constructor called, destructor called, destructor called, destructor called, d. constructor called, constructor called, destructor called, destructor called, | |||
j) | Which of the following statements is not correct?
a. A class can be derived from more than one classes. b. The idea of inheritance implements the is a relationship. c. A class can have one or more constructors. d. We can create an object from an interface. | (2) | |
k) | Which of the following has a stream associated with it?
a. cerr. b. cin. c. cout. d. All of the above have streams associated with them. | (2) | |
l) | Which of the following member function definitions is correct?
a. Always require the scope resolution operator (::). b. Require the scope resolution operator only when being defined outside of the definition of their class. c. Can use the scope resolution operator anywhere, but become public functions. d. Must use the scope resolution operator in their function prototype. | (2) | |
m) | A destructor:
a. Has no parameters. b. Each class can define several destructors. c. Has a return type. d. Both (a) and (b). | (2) | |
n) | Which of the following statements about Const object is (are) true?
a. Const object is the same as a normal object. b. Const object can call any public member functions in the class. c. Const object cannot be changed. d. Const object can be changed by calling const functions in the class. | (2) |
o) | When deriving a class from a public base class, the public members of the base class become and the protected members of the base class become ?
a. protected, private b. public, private c. protected, protected d. public, protected | (2) |