CS II: Study Guide for Exam 1 J.
Maletic
Exam 1 Study Guide
The exam is closed book and closed notes. It is comprehensive and includes all materials covered
during the term so far, in lecture, lab, and on the projects.
Topics covered:
• Abstract Data Type definition
• ADTs: set, point, string, bigint
• Class, constructors, operator overloading
• Const methods
• Pre, post conditions, invariants, assertions
• Software testing
• Overloading I/O operators
Not on the exam: make, svn, or Unix commands
Sample Exam Questions
These questions are representative of the types and format of the exam questions. The
instructor has given similar questions in the past.
1. Given the class definition below, write a member function that checks if two strings (as
defined below) are equal. Give REQUIRES and ENSURES conditions for the operator==
you write.
class String {
public:
string() { s[0] = 0; };
bool operator==(const String&) const;
private:
char s[256]; //null terminated character array
};
2. What are the three components of an abstract data type (ADT)?
3. Overload operator>> for the string class defined in problem 1. You can assume it is a
friend function. Read in a string from a stream until a semicolon (;) is read. Blanks MUST
be included into the string, but the end of line character or semicolon should NOT. You do
not need to check for end of file.
4. Overload operator<< for the bigint class in project 1. You can assume it is a friend
function. Output such that there are a maximum of 60 digits per line. Assume there is a
constant value called BIGINT_CAPACITY.