DOC PREVIEW
UD CISC 181 - Introduction to Computer Science

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CISC181 Introduction to Computer Science Dr. McCoy Lecture 24 Clicker Questions November 24, 2009Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 171CISC181 Introduction to Computer ScienceDr. McCoyLecture 24Clicker QuestionsNovember 24, 2009Given the class definitionclass CreateDestroy {public: CreateDestroy() { cout << "constructor called, "; } ~CreateDestroy() { cout << "destructor called, "; }};What will the following program output?int main() { CreateDestroy c1; CreateDestroy c2; return 0;}2Given the class definitionclass CreateDestroy {public: CreateDestroy() { cout << "constructor called, "; } ~CreateDestroy() { cout << "destructor called, "; }};What will the following program output?int main() { CreateDestroy c1; CreateDestroy c2; return 0;}(a) constructor called, destructor called, constructorcalled, destructor called.(b) constructor called, destructor called.(c) constructor called, constructor called.(d) constructor called, constructor called, destructorcalled, destructor called.3The assignment operator (=) can be used to(a) test for equality.(b) copy the data from one object to another.(c) compare two objects.(d) copy a class.4If the line friend class A; appears in class B, and friend class B; appears in class C then(a) class A is a friend of class C.(b) class A can access private variables of class B.(c) class C can call class A’s private member functions.(d) class B can access class A’s private variables.5Linked lists allow(a) insertions and removals anywhere(b) insertions and removals only at one end(c) insertions at the back and removals from the front(d) none of the above6The __________ operator takes as an argument the type of object being allocated and returns a __________.(a) new, pointer to an object of that type(b) new, reference to an object of that type(c) new, copy of the object of that type(d) sizeof, pointer7__________ is not an advantage of linked lists when compared to arrays.(a) Dynamic memory allocation(b) Efficient insertion and deletion(c) Direct access to any list element(d) Efficient use of memory8Which of the following is false about the new operator and the object it allocates memory for?(a) it calls the object’s constructor.(b) it returns a pointer.(c) it does not require size of the object to be specified.(d) it automatically destroys the object after main is exited.9For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtr is a pointer to the new node to be added, and lastPtr is a pointer to the current last node. Each node contains a pointer nextPtr, which is a link to a node.10Add a node to the end of the list:(a) lastPtr->nextPtr = newPtr; lastPtr = newPtr;(b) lastPtr = newPtr; lastPtr->nextPtr = newPtr;(c) newPtr->nextPtr = lastPtr; lastPtr = newPtr;(d) lastPtr = newPtr; newPtr->nextPtr = lastPtr;11Given the linedelete newPtr;what can you conclude?(a) The memory referenced by newPtr is released only if it is needed by the system.(b) newPtr is of type void *.(c) newPtr only exists if there was an error freeing the memory.(d) newPtr still exists.12A linked list has the functions insertAtFront, removeFromFront, insertAtBack, and removeFromBack, which perform operations on nodes exactly as their names describe. Which two functions would most naturally model the operation of a queue? (a) insertAtBack and removeFromBack.(b) insertAtBack and removeFromFront.(c) insertAtFront and removeFromFront.(d) insertAtFront and removeFromBack.13Which of the following statements will not produce a syntax error?(a) defining a const member function that modifies a data member of an object.(b) invoking a non-const member function on a const object.(c) declaring an object to be const.(d) declaring a constructor const.14The delete operator(a) can terminate the program.(b) can delete an entire array of objects declared using new.(c) must be told which destructor to call when destroying an object.(d) is called implicitly at the end of a program.15The code fragmentIncrement::Increment(int c, int i) : increment (i) { count = c; }tells you(a) Increment is a const variable.(b) Increment must be a const function.(c) increment may or may not be a destructor.(d) increment may be a const variable.16When composition (one object having another object as a member) is used(a) the host object is constructed first and then the member objects are placed into it(b) member objects are constructed first, in the order they appear in the hostconstructor’s initializer list(c) member objects are constructed first, in the order they are declared in the host’s class(d) member objects are constructed last, in the order they are declared in the host’s


View Full Document
Download Introduction to Computer Science
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Computer Science and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Computer Science 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?