Module 2: Chapter Quizzes

44 flashcards · Programming Languages · by Gabriella Torres

  1. A C++ member function that sets or changes the value stored in a member variable is called

    a mutator.

  2. An object typically hides its data but allows outside code to access it through its

    public member functions.

  3. A constructor may have a return type of

    None of the above (none of these: void, int, bool)

  4. A structure variable is similar to a class object in which of the following ways?

    B and C, but not A

  5. A constructor that does not require that any arguments be passed to it is called a(n) ________ constructor.

    default

  6. Accessors are sometimes called ________ functions and mutators are sometimes called ________ functions.

    get, set

  7. If setRadius is a Circle class function and myCircle is a Circle object, which of the following statements would set myCircle's radius to 2.5?

    myCircle.setRadius(2.5 );

  8. The bundling of an object's data and functions together is called

    encapsulation.

  9. A constructor must have the same name as the

    class.

  10. The ________ is used to protect important data.

    private access specifier

  11. When three different objects of a class are created, they are said to be separate ________ of the class.

    instances

  12. In OOP terminology, an object's member variables are often called its ________, and its member functions are sometimes referred to as its ________.

    attributes, methods

  13. A class may have ________ default constructor(s) and ________ destructor.

    only one, only one

  14. A C++ member function that uses, but does not change, the value of a member variable is called

    an accessor.

  15. When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.

    inline

  16. A(n) ________ member function may be called by a statement in a function that is outside of the class.

    public

  17. A destructor is a member function that

    is automatically called when an object is destroyed.

  18. The name of a destructor must begin with

    a tilde (~)

  19. When a member function is defined outside of the class declaration, the function name must be qualified with the class name, followed by

    the scope resolution operator (::).

  20. If Circle is the name of a class, which of the following statements would create a Circle object names myCircle?

    Circle myCircle;

  21. If the scores array is defined like this: int scores [ ] = {4, 7, 4, 8, 9}; What will the following statement display? cout << scores[4];

    9

  22. The elements of an array can be

    Any of the above a. objects b. structures c. strings d. Any of the above e. None of the above

  23. Unlike regular variables, arrays can hold multiple __________

    values

  24. Which of the following statements will correctly carry out the operation stated in the comment to its right?

    None of the above a. array2 = 5; // Place a 5 in each element of array2. b. array 2 = array1 // Copy the elements of array 1 into array 2 c. cout << array2 // Output the elements stored in array 2 d. None of the above e. A and B, but not C

  25. To access an array element, use the array name and the element's __________

    subscript

  26. A two-dimensional array can be viewed as

    a table with rows and columns

  27. To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use __________ loop.

    a for loop

  28. The following two arrays string deptName[3] = {"Manufacturing", "Sales", "Business Office"); double deptBudget[3] = {200000.0, 60000.0, 50000.0}; are an example of __________ arrays.

    parallel

  29. An array can store multiple values, but the values must be __________.

    all the same data types

  30. By using the same _________ you can build relationships between data stored in two or more arrays.

    subscript

  31. The statement int grades[ ] = {100, 90, 99, 80}; is an example of __________

    implicit array sizing.

  32. The following statement for (int val : myArray) cout << val << " "; is an example of a(n) __________

    ranged-base for loop.

  33. To add up all the values in a two-dimensional array it would be best to use __________.

    a nested for loop

  34. Subscript numbering in C++ __________.

    automatically begins with zero

  35. When an array is passed to a function, it is actually __________ the array that is passed.

    the starting memory address of

  36. A sorting algorithm can be used to arrange a set of __________ in __________ order.

    All of the above a. strings, ascending b. numeric values, descending c. numeric values, ascending d. strings, descending e. All of the above

  37. A(n) __________ search is more efficient than a __________ search.

    binary, linear

  38. A binary search begins by examining the __________ element of an array.

    middle

  39. To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?

    100

  40. The advantage of a linear search is that

    Both A and D a. it is simple b. it is fast c. it is efficient d. it can be used on unordered data. e. Both A and D

  41. We can measure the complexity of an algorithm that solves a computational problem by determining the number of __________ for an input of size n.

    basic steps it requires

  42. A search can be performed on an array of

    All of the above, whether the data is in order or not a. strings b. integers c. objects d. All of the above, but only if the data is in order e. All of the above, whether the data is in order or not

  43. The __________ sort usually performs fewer exchanges than the __________ sort.

    selection, bubble

  44. The linear search is adequate for searching through __________ arrays, but not through __________ ones.

    small, large