Test II, CSCI 230, Spring 2013
- The weight for each question is given.
- Use as much paper as you wish, but make your answers are legible.
- Please answer each question thoughtfully and carefully.
- [5 points] Give the definition for Abstract Data Type (ADT).
- [2 points] How are ATDs implemented in C++?
- [4 points] Describe at least two common errors which can be prevented by using classes.
- [2 points] What is information hiding?
- [4 points] What is an array? Name two properties of an array.
- [3 points] Give the syntax for declaring an array. NOTE ALL restrictions.
- [2 points] What is an array index out of bounds error?
- [3 points] What are the potential results of an array index out of bounds error?
- [2 points] What is the effect of declaring a member item of a class private?
- [5 points] Draw a diagram which represents program compilation involving myClass.h, myClass.cpp and main.cpp. Your diagram should include the following terms. Place a rectangle around processes and underline files.
Preprocessor | System Header File | System Library Object File | Executable |
Compiler | Linker | Source Code |
|
- [2 points] Describe how an array is passed as a parameter.
- [3 points] Show how an array be passed so that the values can not be changed. Explain your example.
- [5 points] Write a function which takes an array of integers, and the size of the array , and returns the sum of the values in the array.
- [3 points] Give the three conditions necessary to successfully write a recursive function.
- [5 points] Write a recursive function to calculate the next triangular number T(n).
T(n) = | | 1, n=1 |
| n+T(n-1), n>1 |