Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Suppose inf is an available ifstream and c is an available character. Consider the following code fragment.




1.

 

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.
(b) Characters are read until the end of the file is reached.
(c) Characters are read until a non-white-space character is read or until the end of the file is reached.
(d) The number of non-white-space characters is counted.

 

 

Correct answer is

(c)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.3.3 of the course notes.

 
 

2.

 

In C++, the preprocessor is

 

 

 

(a) a set of APIs provided by several compiler vendors
(b) a virtual CPU that can be used to simulate machine-code execution
(c) a debugging tool common to most visual programming environments
(d) a tool that manipulates source files before compilation

 

 

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
(b) Attaining the highest possible efficiency
(c) Providing elegant mechanisms for code reuse
(d) Implementing simple monolithic programs

 

 

Correct answer is

(a)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.3.2 of the course notes.

 
 

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
(b) 11
(c) 2
(d) 0

 

 

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);
(b) void print(Thing* x);
(c) void print(Thing x);
(d) void print(const Thing& x);

 

 

Correct answer is

(d)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.4.2 of the course notes.

 
 

6.

 

If A is an array of 100 integers, which of the following properly deallocates A?

 

 

 

(a) delete A;
(b) delete [100] A;
(c) delete A[100];
(d) delete [] A;

 

 

Correct answer is

(d)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.4.3 of the course notes.

 
 

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;
(b) None
(c) D.x = 555;
(d) D.z = 555;

 

 

Correct answer is

(a)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.5.1 of the course notes.

 
 

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
(b) Always
(c) If and only if the class uses private inheritance
(d) If and only if the class is not a template class

 

 

Correct answer is

(a)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.5.2 of the course notes.



 
 

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
(b) unions
(c) inheritance
(d) templates

 

 

Correct answer is

(d)

 

 

Your score on this question is:

10.00

 

 

Feedback:


See section 1.5.3 of the course notes.

 
 

10.

 

In C++ exception handling, intermediate exception handlers typically are used to:

 

 

 

(a) ensure allocated resources are properly released
(b) throw user-defined exception classes
(c) override the guarantees of exception specifications
(d) catch exceptions polymorphically

 

 

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? | Постановление Пленума верховного Суда

mybiblioteka.su - 2015-2024 год. (0.016 сек.)