COP 4530: Sample quiz

 

 

1. Assume you are in a directory with the following files:

part1.c, part1.o, part2, poem1, poem2, quiz6

 

What does the following command do? ls po*

 

 

 

2. Assume you are in a directory with the following files:

part1.c, part1.o, part2, poem1, poem2, quiz6

 

What does the following command do? cat *[1-6] > temp

 

 

 

3. Let i, j, and k be integer variables, with i = j = 1, and k = 3. What is the value of l after execution of the following statement?

 

l = (i<<j)&k;

 

 

 

4. Let i, j, and k be integer variables each having value 3. What are their values after execution of the following statement?

 

i *= ++j*k--;

 

 

 

 

5. Define a class called MyInt that has a private int data member called data, two public accessor functions get and set, and a public constructor that takes an int argument.

 

 

 

 

 

 

 

6. Implement the constructor for the class in #5, so that it sets the value of data to the value of its argument.

 

 

 

 

 

7. Implement the get accessor function for the class MyInt.

 

 

8. What is the difference in the restrictions each of the following declarations places on the use of X?

 

(i) const int *X;

(ii) int *const X;

 

 

 

 

 

 

 

9. Why do classes with dynamic memory allocation typically overload the assignment operator?

 

 

 

 

 

 

 

 

 

10. How will you deallocate memory allocated in the following statement:

double *ptr = new double[10];

Quiz solution:

www.cs.fsu.edu/~asriniva/courses/DS14/review/SampleSolution.html