midtermOct2007_solution

midtermOct2007_solution - Part I: True/False and multiple...

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

View Full Document Right Arrow Icon
Part I: True/False and multiple choice answers. Circle your answers on the question sheet, and fill them in on the Scantron form 1. [1 mark] The C++ declaration in function main char a; instantiates one object of type char . a) True b) False 2. [1 mark] The Card class (used in assignments) extends the class VisualCard . a) True b) False 3. [1 mark] The VisualCard class inherits the member function getSuit() from the Card class. a) True b) False 4. [1 mark] A bag is an example of a linear data structure. a) True b) False 5. [1 mark] A member function of a C++ class can be called inside other member functions of the same class a) True b) False 6. [1 mark] The C++ statement in function main Card * p = new Card(CLUBS,N10); instantiates one Card object in a call stack area of memory. a) True b) False (the object is created in a HEAP)
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 7. [1 mark] The C++ statement in function main char p[5]; instantiates an array that can hold 5 char values in a heap area of memory. a) True b) False (this is a statically allocated array, in a CALL STACK) 8. [1 mark] The C++ statement Stack<int> * a = new Stack<int>(4); instantiates an object of type Stack , and stores its address in a . a) True b) False 9. [1 marks] The C++ code sequence Bag<int*> b(6); b.add( &b ); will fail to compile a) True b) False 10. [1 marks] The C++ code sequence in function main Point a; a.m_x = 5; will fail to compile in case m_x is a private member variable of class Point . a) True b) False
Background image of page 2
11. [2 marks] Assume that shift( int , int ) is a public member function of class Point. The C++ code sequence in function main Point p(1,2); shift(5,4); will not compile a) True b) False 12. [2 marks] If function main instantiates Point object Point a(1,2); then code for a member functions of class Point can not contain a line like int a = 4; a) True b) False 13. [2 marks] Suppose we have the C++ declarations int a, *p; Then the statement p = &a; is equivalent to *p = a; a) True b) False 14. [1 mark] Objects that are instantiated using the new operator are created in the heap area of memory. a) True b) False 15. [1 mark] The destructor for a class should never free up memory that was allocated via operator new inside other member functions of that class. a)
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 document was uploaded on 10/26/2009.

Page1 / 12

midtermOct2007_solution - Part I: True/False and multiple...

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