Please use an editor or word processor to answer the questions.
Please label your answers with the question number and part.
Please answer each question thoughtfully and carefully. I expect your answers to demonstration participation in this class.
You may use books, notes and other non-human references. You may not interact with any other person when answering these questions.
Proper use of terminology will be graded.
The test is due at the end of the test session.
Submission instructions are at the end of the test.
Submissions should be done through the D2L assignment folder Final Exam
If you have problems submitting the test, please contact your instructor.
If you have questions, please communicate with your instructor via Zoom's chat feature.
Please use private chat.
Abstract Data Type: An abstract data type (ADT) is defined as a data type whose properties(domain and operations) are specified independently of any particular implementation.
[1 point] What is the domain of an ADT?
[1 point] What are the operations of an ADT?
[4 points] Why is it important that the definition of an ADT does not rely on the implementation?
[2 points] What C++ mechanism is used to implment an ADT?.
[4 points] Describe two mechanisms used in C++ to accomplish information hiding.
Classes vs Structures.
[1 point] What is the purpose of a structure in C++?
[2 points] When should a programmer select a structure over a class when implementing a program in C++?
File Processing.
[2 point] Describe the operation of the ifstream member function eof.
[2 point] describe the exact conditions which must occur for the ifstream member function eof to return true.
[6 point] Describe (exactly) the output from the following code if the file input.dat contains the single value 1. Any error in this description will result in loss of points. Explain how the output value was calculated.
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inFile;
int sum = 0;
int data;
inFile.open("input.dat");
while(not inFile.eof()) {
inFile >> data;
sum += data;
}
inFile.close();
cout << sum << endl;
return 0;
}
Dynamic Memory
[2 points] What does the C++ new operator do?
[2 points] When implementing a class with dynamic memory, why is a destructor required?
When an class object is passed by value
[1 point] what member function is called?
[2 points] What must this member function do?
[2 points] Describe the parameter(s) to this function and how they must be passed.
[2 points] Describe the difference between a deep copy and a shallow copy.
Lists
[4 points] Describe the ADT list. Include all relevant portions from the definition of an ADT.
[2 points] How is a list different from an array?
[6 points] Describe in detail how a list can be implemented in an array.
[4 points] Describe in detail how a list can be implemented as a linked structure.
[2 points] What advantages are gained by implementing a list as a linked structure?
Submission Instructions
Submit your test to the appropriate D2L assignment folder Final Exam by
the end of class.
If you miss this deadline, you can submit your test by email to dbennett@edinboro.edu. Depending on the circumstances, there may be a 5% penalty per minute applied for email submissions.