2004f07.mt2.sampsoln

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

Info iconThis preview shows pages 1–3. 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 A - Object-Oriented Software Development - Fall 2007 Midterm Exam 2 – November 7 th , 2007 Sample Solutions Please read these instructions before you answer any of the exam questions: 1. There are six questions worth 34 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 (9 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 three 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. (½ mark for each part of each question) a) f = f1; 1) static type: Fish 2) dynamic type: Fish 3) error free , compile error, run-time error b) f = b; 1) static type: Fish 2) dynamic type: Bird 3) error free, compile error , run-time error
Background image of page 1

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

View Full Document Right Arrow Icon
Page 2 of 8 c) m = c; 1) static type: Mammal 2) dynamic type: Cat 3) error free , compile error, run-time error d) m = c; h = (Cat) m; 1) static type: Horse 2) dynamic type: Cat 3) error free, compile error , run-time error e) m = c; h = (Horse) m; 1) static type: Horse 2) dynamic type: Horse 3) error free, compile error, run-time error f) m = c; c = (Cat) m; 1) static type: Cat 2) dynamic type: Cat 3) error free , compile error, run-time error Question 2 (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 two questions based on the last line of code given: 1) the name of the method invoked; 2) the class in which the method invoked is found. (½ mark for each part of each question) a) System.out.println(c); 1) method name: toString() 2) in class: Cat
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

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

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

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