22C:30, 22C:115 Review Questions for Exam 1
Exam 1 is scheduled for Friday, September 27, from 10:30 to 11:20 in
Room 321, CB
Given below are questions that you should attempt to answer in studying for
The problems on the exam will involve (i) answering questions about small code
fragments that are given or (ii) writing small code fragments to perform a
specific task. You will not be asked to write large functions or entire classes.
You should read Chapters 1-4 and Section 5.1 for the exam.
Focus of material that relates to what was discussed in class and in the
So for example, Sections 1.2, 3.2, 4.5 etc., are less important than
- Why is a class definition separated into a public and a private portion?
Can data members go into the public portion of a class? Can member functions
go into the private portion of a class?
- What is the difference between passing parameters by value and passing
parameters by reference? Are there other ways of passing parameters, besides
- Why do functions sometimes return a reference? For example, why does
operator  in the apvector class return a reference?
- Why do classes need destructors? For example, the apvector class has one.
- Why do classes need copy constructors? When are copy constructors called
without an explicit function call?
- What are template classes and what are they good for?
- How can we define a 2-dimensional array using the apvector class?
- What is the meaning of the operators * and & in the context of pointers?
- What do the new operator and the delete operator do?
- What is the "this" pointer and what is it good for?
- How would one insert into the back of a linked list? How would one insert
into the front of a linked list? What advantages do linked lists have over