|
| Suppose inf is an available ifstream and c is an available character. Consider the following code fragment. do c = inf.get(); while (!inf.eof() && isspace(c)); Which of the following accurately describes the effect of executing this fragment? |
(a) Characters are read until a white space is read. |
Correct answer is | (c) |
Your score on this question is: | 10.00 |
Feedback: |
|
2. | In C++, the preprocessor is |
(a) a set of APIs provided by several compiler vendors |
Correct answer is | (d) |
Your score on this question is: | 10.00 |
Feedback: | See section 1.3.4, subsection "Text Substitution," in the course notes. |
3. | To which of the following is object-based programming ideally suited? |
(a) Encapsulation |
Correct answer is | (a) |
Your score on this question is: | 10.00 |
Feedback: |
|
4. | Consider the following C++ program segment: int j[10]; for (int i = 0; i < 10; i++) { j[i] = i; } int *a = j; a++; After execution of this program segment, what will be the value of j[0]? |
(a) 1 |
Correct answer is | (d) |
Your score on this question is: | 10.00 |
Feedback: | See section 1.4.1 in the course notes. |
5. | Assume that Thing is a user-defined type. Which of the following print functions for Thing is the safest and most efficient? |
(a) void print(Thing& x); |
Correct answer is | (d) |
Your score on this question is: | 10.00 |
Feedback: |
|
6. | If A is an array of 100 integers, which of the following properly deallocates A? |
(a) delete A; |
Correct answer is | (d) |
Your score on this question is: | 10.00 |
Feedback: |
|
7. | Consider the following inheritance declarations. class Base { public: int x; private: int y; }; class Derived: public Base { public: int z; }; Derived D; Under these declarations, which of the following statements, if any, will fail to compile? |
(a) D.y = 555; |
Correct answer is | (a) |
Your score on this question is: | 10.00 |
Feedback: |
|
8. | Under what circumstances will a member function in C++ display polymorphic behavior? |
(a) If and only if the function is explicitly declared to be virtual |
Correct answer is | (a) |
Your score on this question is: | 10.00 |
Feedback: |
|
9. | The proper tool for writing an array class that can have some instances with integer elements and other instances with float elements is the use of |
(a) casting |
Correct answer is | (d) |
Your score on this question is: | 10.00 |
Feedback: |
|
10. | In C++ exception handling, intermediate exception handlers typically are used to: |
(a) ensure allocated resources are properly released |
Correct answer is | (a) |
Your score on this question is: | 10.00 |
Feedback: | See section 1.5.4, subsection "Using Intermediate Handlers," in the course notes. |
Дата добавления: 2015-11-04; просмотров: 34 | Нарушение авторских прав
<== предыдущая лекция | | | следующая лекция ==> |
Device drivers facilitate communication between which layers of the system? | | | Постановление Пленума верховного Суда |