⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4.txt

📁 icarnegie SSD5 Mutli-choice4-7
💻 TXT
📖 第 1 页 / 共 2 页
字号:
      vector<int>  A(10,20);

Which of the following accurately describes what is created?
 
 

  (a) An array of 10 arrays of ints, each of size 20
 (b) An array of 10 ints, each initialized to 20
 (c) An array of ints, indexed from 10 to 20
 (d) An array of 20 arrays of ints, each of size 10  

 Correct answer is  (b)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 7. 
 Consider the following declaration that makes use of a user-defined class Thing.

      vector<Thing>  A(10);

In order that it compile, the class Thing must have which of the following?
 
 

  (a) a copy constructor
 (b) a default constructor
 (c) a destructor
 (d) an assignment operator  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 8. 
 The capacity of an STL vector is defined to be the  
 

  (a) number of elements currently stored in the vector
 (b) maximum number of elements that can be stored in the vector without resizing
 (c) difference between the current number of elements and the maximum number of elements
 (d) maximum number of elements the vector could possibly have on the given machine  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 9. 
 Which of the following statements is (are) true regarding C-style strings? 

They are terminated by the null character. 
Storing a five-character string requires at least seven characters.
 
 

  (a) I and II
 (b) I only
 (c) II only
 (d) None  

 Correct answer is  (b)  

 Your score on this question is: 0.00  

 Feedback: 
   
See section 2.1, subsection "C-style Strings," in the course notes. 
 
 

--------------------------------------------------------------------------------

 10. 
 Which of the following statements is (are) true regarding strings in C++? 

Strings in C++ are supported by the standard class string. 
A constructor for the class string can accept a C-style string as an argument.
 
 

  (a) II only
 (b) None
 (c) I and II
 (d) I only  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.1, subsection "C-style Strings," in the course notes. 
 
 

--------------------------------------------------------------------------------

 Go to top of assessment.  

 Total score: 40.00 

 ? Copyright 2004 iCarnegie, Inc. All rights reserved.  
View Assessment Result: Multiple-Choice Quiz 4


 

 Your performance was as follows:  

 1. 
 The main abstractions of the Standard Template Library include which of the following? 

Iterators 
Exception handlers 
Algorithms
 
 

  (a) I and III only
 (b) I and II only
 (c) I only
 (d) III only  

 Correct answer is  (a)  

 Your score on this question is: 0.00  

 Feedback: 
   
See section 2.1.1, subsection "STL Overview," in the course notes. 
 
 

--------------------------------------------------------------------------------

 2. 
 For an STL iterator it, execution of the statement

    ++it;

does which of the following?
 
 

  (a) Advances the iterator to the next item.
 (b) Increase by 1 the size of the container pointed to by it.
 (c) Post-increments the item to which the iterator points.
 (d) Pre-increments the item to which the iterator points.  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.1.3 of the course notes.  
 

--------------------------------------------------------------------------------

 3. 
 Which of the following data structures is not a container implemented in the C++ Standard Template Library? 
 
 

  (a) Hash table
 (b) List
 (c) Stack
 (d) Vector  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.1.1, subsection "STL Overview," in the course notes. 
 
 

--------------------------------------------------------------------------------

 4. 
 The STL deque container contains which of the following methods?

push_back 
push_front 
pop_front 
 
 

  (a) I, II, and III
 (b) II and III only
 (c) III only
 (d) I only  

 Correct answer is  (a)  

 Your score on this question is: 0.00  

 Feedback: 
   
See section 2.2.3, subsection "Interface," in the course notes.
 
 

--------------------------------------------------------------------------------

 5. 
 A typical implementation of a deque in the C++ STL minimizes the need to copy elements upon the frontal insertion of new items by
 
 

  (a) using a background thread to reallocate memory when necessary
 (b) inserting the element at the next available position in the deque and maintaining a table of element positions
 (c) reserving memory at the front of the deque's stored elements
 (d) inserting the element at the end of the deque and maintaining a table of element positions  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   
See section 2.2.3, subsection "Implementation," in the course notes.
 
 

--------------------------------------------------------------------------------

 6. 
 In STL vectors, _____ refers to the maximum number of items that can be stored without resizing, and _____ refers to the number of items stored. 
 
 

  (a) size, capacity
 (b) range, domain
 (c) capacity, size
 (d) domain, range  

 Correct answer is  (c)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 7. 
 If A is an STL vector, then the effect of executing the statement

      A[i] = x;

is to
 
 

  (a) create an iterator x pointing to position i in the array
 (b) write x to position i of the vector, without bounds checking
 (c) check array bounds, and write x to position i if and only if i is in the proper range
 (d) check array bounds, enlarge the vector if necessary, and then write x to position i  

 Correct answer is  (b)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 8. 
 Consider the following declaration that makes use of a user-defined class Thing.

      vector<Thing>  A(10);

In order that it compile, the class Thing must have which of the following?
 
 

  (a) an assignment operator
 (b) a destructor
 (c) a default constructor
 (d) a copy constructor  

 Correct answer is  (c)  

 Your score on this question is: 10.00  

 Feedback: 
   See section 2.1.2 of the course notes.  
 

--------------------------------------------------------------------------------

 9. 
 A C-style string is stored as an array of characters that ends with _____ character. 
 
 

  (a) a '\0'
 (b) a '\n'
 (c) any white-space
 (d) a '0'  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   
See Chapter 2, page 74, in the course textbook.
 
 

--------------------------------------------------------------------------------

 10. 
 Consider the following C++ program segment, assuming that string is a class. 

   string str1("Hello, World");
   str1[5] = 'Z';
The overloaded operator[] function invoked in the above program segment should have which of the following return types? 
 
 

  (a) char &
 (b) char
 (c) const char &
 (d) char *  

 Correct answer is  (a)  

 Your score on this question is: 10.00  

 Feedback: 
   
See Chapter 2, pages 79–81, in the course textbook. 
 
 

--------------------------------------------------------------------------------

 Go to top of assessment.  

 Total score: 70.00 

 ? Copyright 2004 iCarnegie, Inc. All rights reserved.  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -