Computer Science



Item Name

1. What is the advantage of using a function instead

1. What is the advantage of using a function instead of directly accessing data? A. The function can be optimized by the compiler to provide faster access B. The function can hide the implementation of the function from callers, making it easier to change the caller of the function C. Using functions is the only way to share the same data structure across multiple source code files D. There is no...

1. What is the correct value to return to the

1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value. 2. What is the only function all C++ programs must contain? A. Start() B. System() C. Main() D. Program() 3. What punctuation is used to signal the beginning and end of code blocks? A. { } B. -> and

1. What is the final value of x when the

1. What is the final value of x when the code int x; for(x=0; x

1. What is the primary virtue of a binary tree?

1. What is the primary virtue of a binary tree? A. It uses pointers B. It can store arbitrary amounts of data C. It allows fast lookups of data D. It is easy to remove from the binary tree 2. When would you consider using a linked list instead of a binary tree? A. When you need to maintain data in a way that allows fast lookups B. When you want to be able to access the elements in sorted order C....

1. What variable type should you use if you want

1. What variable type should you use if you want to store a number like 3.1415? A. Int B. Char C. Double D. String 2. Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. == 3. How do you get access to the string data type? A. It is built into the language, so you don't need to do anything B. Since strings are used for IO, you include the iostream header...

1. What will happen if you don’t call srand before

1. What will happen if you don’t call srand before calling rand? A. Rand will fail B. Rand will always return 0 C. Rand will return the same sequence of numbers every time your program runs D. Nothing 2. Why would you seed srand with the current time? A. To ensure your program always runs the same way B. To generate new random numbers each time your program is run C. To make sure that the...

1. When do you need to write a constructor for

1. When do you need to write a constructor for a class? A. Always, without the constructor you can't use the class B. Whenever you need to initialize the class with non-default values C. Never, the compiler will provide a constructor for you all the time D. Only if you need to have a destructor too 2. What is the relationship between the destructor and the assignment operator? A. There isn't any...

1. When does the destructor for a superclass get run?

1. When does the destructor for a superclass get run? A. Only if the object is destroyed via a call to delete on a pointer to the superclass B. Prior to the destructor of the subclass being called C. After the destructor of the subclass is called D. While the destructor of the subclass is called 2. Given the following class hierarchy, what would you need to do in the constructor for Cat? class...

1. When is using a vector appropriate? A. You need

1. When is using a vector appropriate? A. You need to store an association between key and value B. You need to be able to maximize performance when changing the collection of items C. You don’t want to worry about the details of updating your data structure D. Like a suit at a job interview, a vector is always appropriate 2. How do you remove all items at once from a map? A. Set the item to an...

1. When should you use a using namespace directive? A.

1. When should you use a using namespace directive? A. In all header files, right after the include B. Never, they are a dangerous crutch C. At the top of any cpp file where there's no namespace conflict D. Right before you use a variable from that namespace 2. Why do we need namespaces? A. To provide compiler writers some interesting work B. To provide more encapsulation of code C. To prevent...