2004w08c.mt2.sampsoln

2004w08c.mt2.sampsoln - Carleton University Department of...

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

View Full Document Right Arrow Icon
Page 1 of 8 Carleton University Department of Systems and Computer Engineering SYSC 2004 C - Object-Oriented Software Development – Winter 2008 Midterm Exam 2 – March 13 th , 2008 – Sample Solutions Please read these instructions before you answer any of the exam questions: 1. There are six questions worth 35 marks on 8 pages. 2. The midterm exam is closed book. Calculators are not permitted. 3. Do not talk to any other students from the time the exam begins until your completed exam has been submitted and you have left the exam room. 4. Ask a question only if you believe there is a mistake on the exam. Otherwise, make a reasonable assumption and proceed. 5. All questions relate to the class diagram on the last page of this exam. You may remove this page and keep it. All other pages must be handed in. Question 1 (6 marks) For all parts of this question, assume the object declarations and initializations, as well as the class diagram on the last page. In each part you are given one or two lines of code and are to answer the following questions based on the last line of code given : 1) the static type of the left hand side of the line of code; 2) the potential dynamic type of the left hand side of the line of code; 3) whether this line of code is error free, or produces a compile-time error, or produces a run-time error. (1 mark for each question. Note that you will lose ½ mark for each incorrect answer. Thus you get 0 if 0 or 1 of the parts are correct; ½ if 2 of the 3 parts are correct; and 1 if all 3 parts are correct.) a) b1 = b; 1) static type: Bird 2) dynamic type: Bird 3) error free, compile error, run-time error: error free b) b = f; 1) static type: Bird 2) dynamic type: Fish 3) error free, compile error, run-time error: compile error
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2 of 8 c) m = h; 1) static type: Mammal 2) dynamic type: Horse 3) error free, compile error, run-time error: error free d) m = c; h1 = (Horse) m; 1) static type: Horse 2) dynamic type: Horse 3) error free, compile error, run-time error: run-time error e) m = c; h = (Cat) m; 1) static type: Horse 2) dynamic type: Cat 3) error free, compile error, run-time error: compile error f) m = c; c = (Cat) m; 1) static type: Cat 2) dynamic type: Cat 3) error free, compile error, run-time error: error free
Background image of page 2
Page 3 of 8 Question 2 (6 marks) For all parts of this question, assume the object declarations and initializations, as well as
Background image of page 3

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

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

This note was uploaded on 02/24/2010 for the course SYSC 2004 taught by Professor L.marshall during the Fall '10 term at Carleton.

Page1 / 8

2004w08c.mt2.sampsoln - Carleton University Department of...

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

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