Object-Oriented Programming Test
Back to activity index

Object-Oriented Programming Test

Fill in the form below and click the [Mail to Instructor] button to mail your answers to the instructor.

Administrative Information

Please select your group from the list:

Name of the Captain:

E-mail address of the Captain:

Name of the Recorder:

E-mail address of the Recorder:

Name of the Reflector:

E-mail address of the Reflector:


Vocabulary

Select the best answer for each question below:
  1. Array
    1. A data structure that allows a single storage location to store multiple values.
    2. A set of storage locations with a common name.
    3. A matrix.
  2. Index
    1. A pointer to a memory location in an accessible part of the declared memory.
    2. An integer that selects a particular element of an array.
    3. A table of contents of a project.
  3. Character strings
    1. An array of characters.
    2. A string of numbers.
    3. A string of letters and numbers.
  4. Object
    1. A thing, such as a telephone.
    2. Code and data packaged together.
    3. An objection to code by the compiler.
  5. Classes.
    1. The subdivision of C++ programming structures into groups of related constructs.
    2. The C++ implementation of objects.
    3. Courses you take at school.
  6. Member functions
    1. Hmmmmmm....
    2. Functions that are member of a program
    3. Functions that belong to an object
  7. Private data.
    1. A soldier's statistics
    2. A bathroom's statistics
    3. Data in an object that the object may use.
    4. Data in an object that the member functions of the object may use.
    5. Data in an object that main may use.
    6. Data in an object that main and the member functions of the object may use.
  8. Public data:
    1. The government's statistics
    2. Data in an object that the object may use.
    3. Data in an object that the member functions of the object may use.
    4. Data in an object that main may use.
    5. Data in an object that main and the member functions of the object may use.

Critical Thinking Questions

Select the best answer for all questions below:
  1. float vector[3];
    1. declares storage for 3 floating point numbers.
    2. declares storage for 3 vectors.
    3. declares storage for 2 floating point numbers since the last one is NULL.
    4. declares storage for 2 vectors since the last one is NULL.
  2. int primes[3]; primes[0]=1; primes[1]=2; primes[2]=3; primes[3]=5;
    1. is legal.
    2. is illegal; primes[0] does not exist.
    3. is illegal; primes[3] does not exist.
    4. is illegal; only primes[3] exists.
    5. is illegal; an index is needed within the brackets, not an integer.
  3. To print out the primes from the previous question, use
    1. cout << primes[3] << ' ';
    2. if (i<=3) cout << primes[3] << ' ';
    3. if (i<=3) cout << primes[i] << ' ';
    4. for (i=0; i<3; i++) cout << primes[3] << ' ';
    5. for (i=0; i<3; i++) cout << primes[i] << ' ';
    6. i=0; while (i<3) cout << primes[++i] << ' ';
    7. i=1; while (i<3) cout << primes[i++] << ' ';
    The following program is intended to print out the primes ``1 2 3 5 7 11 13 17 19 23'':
       #include <iostream.h>
    
       void print_primes(int array[], int size)
       {
           int i;
           for (i=0; i<size; i++) cout << array[i] << " ";
       }
    
       void main(void)
       {
           int primes[10] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23};
           print_primes(primes, 10);
       }
    
  4. In the above program,
    1. the name ``array'' in print_primes must be replaced by ``primes''.
    2. the name ``array'' in print_primes could be replaced by ``primes''.
    3. the name ``array'' in print_primes cannot be replaced by ``primes''.
  5. In the parameter list in the definition of print_primes,
    1. 10 must be inserted within [].
    2. 10 can be inserted within [].
    3. 10 cannot be inserted within [].
  6. In the definition of print_primes above, the loop
       for (i=0; i<size; i++) cout << array[i] << " ";
    
    1. should be
         for (i=1; i<=size; i++) cout << array[i-1] << " ";
      
    2. should be
         i=0; while (i<size) cout << array[i++] << " ";
      
    3. could be any of these
  7. In the declaration of the array of primes, 10 primes are stored.
    1. That is OK.
    2. That is wrong; the last storage location must be NULL.
    3. That is OK; the first storage location is numbered [0]; NULL is stored in location [10]
    4. That is wrong; the first storage location is numbered [0], but the last location is [9]; there is no place for NULL.
  8. The call print_primes(primes, ...
    1. is OK.
    2. should be print_primes(primes[], ...
    3. should be print_primes(primes[0], ...
    4. should be print_primes(primes[10], ...;
  9. The 10 in print_primes(primes, 10);
    1. is OK.
    2. should be 9.
    3. should be 11.
  10. Which declaration is incorrect:
    1. char the_great[3]="LvD";
    2. char the_great[4]="LvD";
    3. char the_great[5]="LvD";
    4. char the_great[]="LvD";
  11. For that example,
    for (i=0; the_great[i]; i++) cout << the_great[i] << ' ';
    1. will not compile: a condition is needed after the first semi-colon.
    2. prints out ``LvD''
    3. prints out ``L v D ''
  12. For that example, for (i=0; the_great[i]; i++);
    1. does nothing, the statement is empty.
    2. outputs ``LvD'' to the screen.
    3. counts the number of letters in ``LvD''.
    4. counts one more.
  13. for (digit='0', i=0; digit<='9'; digit++) string[i++]=digit';
    1. is wrong; you cannot increment characters.
    2. puts the characters '0' through '9' in the first ten positions of string.
    3. Creates the character string ``0123456789''.
  14. Does name[0]='L'; name[1]='v'; name[2]='D' set the string name equal to ``LvD''?
    1. No, you need to close the string ``LvD'' with name[3]=NULL.
    2. Yes. The computer will add NULL to the end of the string automatically.
    Consider the following class declaration:
        class student_object
        {
        private:
           char name[30];
           float GPA;
           void input_name(void);
           void input_GPA(void);
        public:
           void input_data(void);
           void cout_name(void) {cout << name;};
           float get_GPA(void) {return GPA;};
        }
    
  15. Class student_object
    1. is illegal. An object is a thing, not a person.
    2. is legal.
  16. void input_name();
    1. is illegal; a function cannot be within brackets.
    2. is the definition of a private member function of class student_object.
    3. is the prototype of a private member function of class student_object. The function definition will be elsewhere.
  17. void cout_name();
    1. is illegal; a function cannot be within brackets.
    2. is the definition of a public member function of class student_object.
    3. is the prototype of a public member function of class student_object. The function definition will be elsewhere.
  18. Variable GPA can be used
    1. by function main.
    2. by the member functions of student_object
    3. by both
    4. by neither
  19. Function get_GPA can be used
    1. by function main.
    2. by the member functions of student_object
    3. by both
    4. by neither
  20. Inside main, the declaration student_object student1, student2;
    1. is wrong. You can declare things to be float, int, or char, but not student_object!
    2. creates storage for two floating point numbers.
    3. creates two students which must have the same name and GPA.
  21. Inside main, cin >> student_object.GPA;
    1. is correct.
    2. is illegal; student_object is just a description: you first need to create an actual student_object.
  22. Inside main, cin >> student1.GPA;
    1. is illegal: GPA is private.
    2. is correct: private data can be used inside main.
    3. is correct: private data can be used inside main since student_object student1 was created by main.
  23. Inside main, to print out student1's name, use:
    1. cout << student1.name;
    2. cout << student1.name[];
    3. student1.cout_name();
    4. cout << student1.cout_name();
  24. Inside main, to print out student2's GPA, use:
    1. cout << GPA;
    2. cout << student2.GPA;
    3. student2.get_GPA();
    4. cout << student2.get_GPA();
  25. Inside a function with prototype void process_student (student_object student) the statement if (student.GPA > 2.) cout << ``Good student'';
    1. is legal.
    2. is illegal.
  26. Inside a function with prototype void process_student (student_object student) the statement if (student.get_GPA > 2.) cout << ``Good student'';
    1. is legal.
    2. is illegal.

Assessments

Give two strengths of your group:

Give two areas of improvement of your group:

Give two insights obtained about your group:


Give two strengths of the class:

Give two areas of improvement of the class:

Give two insights obtained about the class:


Submission

When all is OK, press the Mail to Instructor button. The Reset button will clear all fields.

Back to activity index