CS 201 – A Blast of a Midterm
  1. What TYPE is the following expression?
    "hello world"

  2. What TYPE is the following expression?
    new Rhino();
  3. What TYPE is the following expression? Assume an Rhino is declared as shown below.
    *(r->next->next);

    Rhino *r = new Rhino();
    Rhino: public Animal {
        int age;
        bool gender;
        Rhino *next;
    }

  4. I have an unordered linked list with 1,000 items.  I wish to search for the occurance of a specific item known to be on the list.  How many items on average must I inspect.


  5. Given the sizes below, how many bytes are needed to store a linked list of 1000 doubles.
    sizeof(double) = 8;    sizeof(float) = 4; sizeof(any pointer) = 4;  sizeof(int) = 4; cizeof(char) = 1;

  6. What happens when I run this code?
    char *ptr = new char[10];
    cout << "Length is " << strlen(ptr) << endl;

  7. CS 201 – A Blast of a Midterm

    What does the code below do?
    int herd = 1; int *h = &herd; int size = 2; int *d = &size;
    herd = 12;
    *d = 17;
    cout << size;

  8. Does a normal operator* on an object call new?
    yes, normal
    no, not normally

  9. Which takes less room to store, a C style string (char * with null byte) or a Pascal style string?

  10. Which of these lines calls a constructor?  
    r = new Rhino();
    Rhino r;

  11. Here are two functions.  Which is likely faster?
       print(Rhino r) { cout << r.age << endl; }
       print(Rhino &r) { cout << r.age << endl; }
  12. In the question above, which function calls the constructor?
  13. CS 201 – A Blast of a Midterm

    Tell me something that a linked list is better at than an array, and something a linked list is worse at.
    LL is better because:
    _________________________________________________________________
    Linked list is worse because:
    ________________________________________________________________

  14. When does a class likely need an operator=()?

  15. The class ‘Group’ in http://euclid.nmu.edu/~randy/Classes/CS201/Tests/Final2001/Group.cpp. Fix it.

  16. When are destructors for a class called?

  17. Write me a program that prints the value of the 100th byte of it's EXECUTABLE.

  18. Change the program at http://euclid.nmu.edu/~randy/Classes/CS201/range.cc such that it compiles and runs.

  19. Change the program at http://euclid.nmu.edu/~randy/Classes/CS201/range.cc such that the class 'Range' is template-ized.