Docsity

CSE687 Object Oriented Design MidTerm Makeup Examination - Spring 2002 - Prof. James Fawce, Exams of Engineering

Toggle sidebar
bg1
CSE687 Object Oriented Design MidTerm Makeup Spring 2002
Midterm Makeup – Take Home Examination
Please prepare complete answers for 30 of the following 31 questions.
This is a take-home makeup examination. You may discuss any of the
questions with me, the TAs, or your friends. The answers you supply,
however, have to be yours, in your own words, and not simply slight
modifications of a midterm prepared by someone else – I do check.
These are due by the last day of classes.
If your answers are essentially flawless, your grade will be raised to 85.
There is no way to raise your midterm score higher than that. If I find
any significant errors, your grade will remain as it is. That is, no credit
will be given for this makeup unless there are no errors in any
question.
The purpose of these rules is to make you think very carefully about
the material, checking with me if you have any doubts, and to prepare
solutions that will make these issues clear to you.
pf3
pf4
pf5

Partial preview of the text

Download CSE687 Object Oriented Design MidTerm Makeup Examination - Spring 2002 - Prof. James Fawce and more Exams Engineering in PDF only on Docsity!

Midterm Makeup – Take Home Examination

Please prepare complete answers for 30 of the following 31 questions. This is a take-home makeup examination. You may discuss any of the questions with me, the TAs, or your friends. The answers you supply, however, have to be yours, in your own words, and not simply slight modifications of a midterm prepared by someone else – I do check. These are due by the last day of classes. If your answers are essentially flawless, your grade will be raised to 85. There is no way to raise your midterm score higher than that. If I find any significant errors, your grade will remain as it is. That is, no credit will be given for this makeup unless there are no errors in any question. The purpose of these rules is to make you think very carefully about the material, checking with me if you have any doubts, and to prepare solutions that will make these issues clear to you.

  1. Implement a function that accepts an STL container and computes the square root of the sum of the squares of its contents. Your function must be able to accept more than one type of container, say either a list or a vector, but you are required to show only that it is correct for a vector. Under what circumstances will your implementation fail to compile?
  2. What are the main design strategies used in Object Oriented Design?
  3. Suppose that you are assigned the task of designing a software system to manage admission of students to a University. Sketch the relationships, using OMT or UML diagrams, between the 5 most important classes in your design. How would you support the Open/Closed principle in this design? You are not expected to know the details of how SU’s admissions system works, but only to invent some reasonable process as part of your design.
  4. Define a base class B and two derived classes D1 and D2 so that B provides a function, clone, that a client can use to create a copy of an object of either derived class, as shown below. B should not have to know the names of the derived classes: D1 d1; D1 *pD1 = D1::clone(d1); D2 d2; D2 *pD2 = D2::clone(d2);
  5. Given the classes: class A { public: virtual void fun1(int); virtual int fun2(); void fun3(); … }; class B : public A { public: void fun1(int); virtual void fun4(); … } what happens when the following code is executed? Are all of these operations correct? A* p = new B; … p->fun1(3); delete p;
  6. Please provide the definition of a function that accepts an array of pointers to functions with the signature int func(X &x), invokes each of the functions, and returns the sum of the computed values.

the most important attributes for your relationship with your program.

  1. Describe all of the essential attributes of a module, as defined in the class notes and described in class.
  2. Write a program that will successfully compile and link that declares an STL vector of STL lists and puts a list of the first 3 positive integers on the vector.
  3. Given the partial class declaration: class D : public B { private: int x; public: D(const D &d); // some more public stuff here }; Show how to correctly define an assignment operator for class D.
  4. Given the class relationship: class D : public B { ... }; what does the following definition imply? D::D(const D &d) : B(d) { ... } What happens when the statements below are executed? D d1; D d2 = d1; B b = d2;
  5. How would a class prevent clients from copying or assigning objects of the class.
  6. Suppose that objects of a class are required to correctly carry out copy and assignment operations. Support or refute the claim that the class must implement a copy constructor and assignment operator.
  1. Suppose that we have the class relationship: class D : public B { ... }; and the function declarations: void fun1(B b); and void fun2(B &b). What can we say about the operations: D d; fun1(d); fun2(d);
  2. Given the partial class declaration: class D : public B { private: int x; public: D(const D &d); // some more public stuff here }; Show how to correctly define a copy constructor for class D.
  3. Write a program that will successfully compile and link that declares an STL vector and puts a standard C++ string object containing your name on the vector.
  4. How do you build a program using modules (this question is not concerned with the things you might have to do in the Visual C++ IDE to work with modules).
  5. What is object oriented design?
  6. What is the purpose of an abstract base class?