f09final - EECS 280 Fall 2009 Final Exam This is a...

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

View Full Document Right Arrow Icon
EECS 280 – Programming and Elementary Data Structures Page 1 of 15 EECS 280 – Fall 2009 Final Exam This is a closed-book exam; no notes or electronic devices are allowed. Write your uniqname on the top of each page of the exam (not the first page). You are responsible for the legibility of your work. Any work that is not clear to the grader due to sloppiness or poor handwriting will be marked incorrect. Each question provides a box for your answer and you must put your answer in the box. Read each question carefully and note all that is required of you. Read the entire exam before you begin working and work on the problems you find easiest first. You are to abide by the University of Michigan / Engineering Honor Code. You must read and sign the Honor Code below. Name: __________________________________ Uniqname: _______________________________ Question No 1 2 3 4 5 Total Grade Possible Points 20 20 20 20 20 100 I have neither given nor received aid on this examination, nor have I concealed a violation of the Honor Code. Signature: ____________________
Background image of page 1

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

View Full DocumentRight Arrow Icon
Uniqname: ________________________ EECS 280 – Programming and Elementary Data Structures Page 2 of 15 Question 1 – Classes In this question, you will be asked to state properties about the following classes: class Pet { char name[50]; public: virtual int train(char * x, int y, char * z[]) = 0; }; class Dog : public Pet { protected: int bark; public: int train(char * x, int y, char * z[]); // REQUIRES: x is a valid C-String and y is a positive integer. // z points to an array of valid C-Strings // EFFECTS: returns how long it will take to train the dog named // x a total of y tricks. virtual int learn_trick(Pet & p); // EFFECTS: returns how long it takes p to learn a “trick” }; class BadDog {}; class Collie : public Dog { int big; public: int train(char * x, int y, char * z[]); // REQUIRES: y is a positive integer. // z points to an array of valid C-Strings // EFFECTS: throws BadDog if x is not a valid C-String or x // does not appear in array z. Otherwise, returns the // number of weeks it will take to train the dog named // x a total of y tricks char * longerName(char * x, char * y); // REQUIRES: x and y are both valid C-Strings // EFFECTS: Returns x if x contains more characters than // y, returns y otherwise. }; class Sheltie : public Dog { private: int small; public: int learn_trick(Pet & p) { return Dog::learn_trick(p); } };
Background image of page 2
Uniqname: ________________________ EECS 280 – Programming and Elementary Data Structures Page 3 of 15 1.a Subtypes Is Collie a subtype of Dog ? Why or why not? Put your answer in the box below: Is Sheltie a subtype of Dog ? Why or why not? Put your answer in the box below: 1.b Visibility Assume the following four statements are added to the method Sheltie::learn_trick() : a) big = 1337; b) small = 10; c) bark = small; d) cout << name << “ is a good dog!” << endl; For each statement, state whether or not the statement will produce a compiler error when the program is
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 12/14/2010 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 15

f09final - EECS 280 Fall 2009 Final Exam This is a...

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