COMP-202--final-exam--2009-12

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

Info iconThis preview shows pages 1–8. 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

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-202A - Introduction to Computing I (Fall 2009) - All Sections Final Examination Wednesday, December 16, 2009 Examiners: Mathieu Petitpas [Section 1 and 3] 9:0012:00 Kamal Zellag [Section 2] 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 22-23 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 26 pages including this cover page, and is printed on both sides of the paper. Pages 24-26 contain information about useful classes and methods. 1 2 3 Subtotal /5 /5 /5 /15 4 5 Subtotal /10 /15 /25 6 7 8 Subtotal /30 /15 /15 /60 Total /100 1 COMP-202A - Fall 2009 - Final Examination Page 2 Section 1 - Short Questions 1. In one or two sentences, explain each of the following concepts. BE BRIEF ; overly long answers [5] will be grounds for mark deductions. (a) Loop (b) Method (c) Reference variable COMP-202A - Fall 2009 - Final Examination Page 3 (d) Class (in the context of object-oriented programming) (e) Constructor COMP-202A - Fall 2009 - Final Examination Page 4 2. In one or two sentences, explain the meaning of each of the following Java reserved words. BE [5] BRIEF ; overly long answers will be grounds for mark deductions. (a) final (b) public (c) void COMP-202A - Fall 2009 - Final Examination Page 5 (d) return (e) new COMP-202A - Fall 2009 - Final Examination Page 6 3. Consider the following program. [5] public class MyInteger { private int x; public MyInteger(int myX) { x = myX; } public double add(int y, int z) { System.out.println("add(int, int): " + x + " + " + y + " + " + z); return x + y + z; } public double add(int y, double z) { System.out.println("add(int, double): " + x + " + " + y + " + " + z); return x + y + z; } public double add(double y, double z) { System.out.println("add(double, double): " + x + " + " + y + " + " + z); return x + y + z; } public static void main(String args) { MyInteger n1 = new MyInteger(1); MyInteger n2 = new MyInteger(2); double r1, r2, r3, r4; r1 = n1.add(3, 4); r2 = n2.add(3, 4); r3 = n1.add(5, 6.0); r4 = n2.add(7.0, 8.0); System.out.println("n1.add(3, 4) == " + r1); System.out.println("n2.add(3, 4) == " + r2); System.out.println("n3.add(5, 6.0) == " + r3); System.out.println("n4.add(7.0, 8.0) == " + r4); } } The program compiles without error and terminates normally when it is executed; what does it dis- play? COMP-202A - Fall 2009 - Final Examination Page 7 WRITE THE PROGRAMS OUTPUT IN THE SPACE BELOW: Total marks for Section 1: 15 COMP-202A - Fall 2009 - Final Examination...
View Full Document

Page1 / 26

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

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

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