# COMP 202 Study Guide - Final Guide: Negative Number, The Wheel Of Time, Dynamic Array

51 views22 pages
11 Apr 2012
School
Course

Student Name: Student Number:
Section:
Faculty of Science
Final Exam
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]
Associate Examiner: Prof. Laurie Hendren
Instructions:
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
Total
/100
1
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 22 pages and 3 million more documents.

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 [2]
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. [2]
(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.
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 22 pages and 3 million more documents.

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. [2]
int i = 0, sum = 1;
do {
boolean more;
i++;
sum *= i;
if (i > 6)
more = false;
else
more = true;
} while(more);
System.out.println(sum);
4. Consider the following array declaration: [3]
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.
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 22 pages and 3 million more documents.