COMP-202--final-exam--2009-04

COMP-202--final-exam--2009-04 - First Name : Last Name :...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: First Name : Last Name : McGill ID : Section : Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) - All Sections Final Examination Wednesday, April 29, 2009 Examiners: Mathieu Petitpas [Section 1] 9:0012:00 Prof. Xue Liu [Section 2] Ekwa J. Duala-Ekoko [Section 3] Instructions: DO NOT TURN THIS PAGE UNTIL INSTRUCTED This is a closed book final examination; notes, slides, textbooks, and other forms of documentation are not allowed. Non-programmable calculators are allowed (though you should not need one). Computers, PDAs, cell phones, and other electronic devices are not allowed. Answer all questions on this examination paper and return it. If you need additional space, use pages 21-22 or the booklets supplied and clearly indicate where each question is continued. In order to receive full marks for a question, you must show all work. This final examination has 24 pages including this cover page, and is printed on both sides of the paper. Pages 23-24 contain information about useful classes and methods. 1 2 3 Subtotal /10 /5 /5 /20 4 5 6 Subtotal /10 /10 /10 /30 7 8 9 Subtotal /15 /20 /15 /50 Total /100 1 COMP-202B - Winter 2009 - Final Examination Page 2 Section 1 - Short Questions 1. In one or two sentences, explain the differences between the concepts in each of the following pairs. [10] BE BRIEF ; overly long answers will be grounds for mark deductions. (a) An if statement and a while statement (b) Classes and objects (c) Instance variables and class (or static) variables COMP-202B - Winter 2009 - Final Examination Page 3 (d) An array and an ArrayList (e) Checked exceptions and unchecked exceptions 2. The most common method students encounter in this course is the main() method; its header can [5] have slight variations but is usually the following: public static void main(String args) In one or two sentences, describe what each of the following elements of the header of the main() method means. BE BRIEF ; overly long answers will be grounds for mark deductions. (a) public COMP-202B - Winter 2009 - Final Examination Page 4 (b) static (in the context of methods) (c) void (d) String args COMP-202B - Winter 2009 - Final Examination Page 5 3. On December 31 st , 2008, first-generation portable music players of a well-known brand seemingly [5] refused to start. The problem was linked to the following code fragment, which is part of the start-up program of the music player: year = ORIGINYEAR; / * = 1980 in the actual code, but assume 2008 for the purposes of this question; the bug occurs regardless of the actual value * / while (days > 365) { if (isLeapYear(year)) { if (days > 366) { days = days - 366; year = year + 1; } } else { days = days - 365; year = year + 1; } } The above code attempts to calculate the year based on the the value of the days variable, which rep- resents the total number of days since January 1 st in the year given by the value of the ORIGINYEAR variable....
View Full Document

Page1 / 24

COMP-202--final-exam--2009-04 - First Name : Last Name :...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online