COMP 202 Study Guide - Final Guide: Negative Number, The Wheel Of Time, Dynamic Array
51 views22 pages
For unlimited access to Study Guides, a Grade+ subscription is required.
Student Name: Student Number:
Faculty of Science
COMP-202A - Introduction to Computing I (Fall 2007)
Friday, December 14, 2007 Examiners: Mathieu Petitpas [Section 1]
14:00–17:00 Prof. Clark Verbrugge [Section 2]
Ladan Mahabadi [Section 3]
Associate Examiner: Prof. Laurie Hendren
•DO NOT TURN THIS PAGE UNTIL INSTRUCTED
•This is a closed book exam.
•Calculators are allowed (though you should not need one).
•Translation dictionaries are allowed (human languages only).
•You must return the exam paper.
•Answer all questions on the exam paper; if you need additional space, use the last page or the booklets
supplied and clearly indicate where each question is continued. In order to receive full marks, you must
show all work.
•This exam has 22 pages including this cover page. Note that for your convenience the last page has a generic
list of useful classes and methods that may be helpful in programming questions.
1 2 3 4 5 6 7 8 9 SubTotal
/2 /2 /2 /3 /4 /1 /3 /2 /3 /22
10 11 12 13 14 15 16 17 SubTotal
/4 /4 /6 /5 /5 /5 /4 /5 /38
18 19 20 SubTotal
/12 /15 /13 /40
COMP-202A Fall 2007 Exam Page 2
Section 1 - Short Answer Questions
1. In one or two sentences, explain the differences between the concepts in each of the following pairs. BE 
BRIEF; overly long answers will be grounds for mark deductions.
(a) Primitive types and reference types, with regards to how they are stored in memory.
(b) Classes and objects.
2. The following question deals with exceptions. 
(a) In one or two sentences, explain the difference between checked and unchecked exceptions. BE BRIEF;
overly long answers will be grounds for mark deductions.
(b) List one unchecked exception type and one checked exception type deﬁned in the Java platform.
COMP-202A Fall 2007 Exam Page 3
3. There is a problem in this code fragment; explain what it is and how to ﬁx it. 
int i = 0, sum = 1;
sum *= i;
if (i > 6)
more = false;
more = true;
4. Consider the following array declaration: 
int anArray = new int[n];
Suppose that nhas already been assigned some non-negative input value and the programmer would like to
apply the method f(int) to each element of the array. Give two ways of doing so, one based on a for loop,
and one based on a for-each loop.