cs12_05spr_002_mt_sol

cs12_05spr_002_mt_sol - Last name First name SID(last 4...

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

View Full Document Right Arrow Icon
Last name: _____________________ First name: ___________________________ SID (last 4 digits): __________ login id: __________ CS 012 – Intro to Computer Science II Spring - 2005 Mid-term exam Section 002 – Friday 4/29 – total 100 points SOLUTION Time : 50 mins. You may have on your desks ONLY this exam, your personalized multiple choice answer sheet, a writing implement and an eraser, and your student ID. You may use a separate sheet(s) of scratch paper. Make good use of this – don’t write your answers in the assigned space until you are sure of them! WRITE CLEARLY IN THE SPACE PROVIDED. WARNING !!!: POINTS WILL BE DEDUCTED FOR MESSY & HARD-TO-READ HANDWRITING!!! Section I (questions 1 to 25) are to be answered on your multiple choice answer sheets; Section II (questions 1 to 3) on this exam booklet. Hand both in together. You will be required to show your student ID when you hand in your exam. Be sure to read each problem carefully and follow the directions. Section I 50 Section II Q.1 25 Section II Q.2 10 Section II Q.3 15 TOTAL 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
Last name: _____________________ First name: ___________________________ Section I: Multiple choice – 2 points each 1. Which of the following correctly goes through and prints out all the elements of a vector named myVec? a. for (unsigned int j = 0 ; j < myVec.size() ; ++j) cout << myVec[j] << endl ; b. for (unsigned int j = 0 ; j <= myVec.size() ; ++j) cout << myVec[j] << endl ; c. for (unsigned int j = 1 ; j < myVec.size() ; ++j) cout << myVec[j] << endl ; d. for (unsigned int j = 1 ; j <= myVec.size() ; ++j) cout << myVec[j] << endl ; 2. Which sections of a class can a member function of that class access? a. Private b. Protected c. Public d. All of the above e. None of the above 3. Which sections of a class can a non-member function access? a. Private b. Protected c. Public d. All of the above e. None of the above 2
Background image of page 2
Last name: _____________________ First name: ___________________________ 4. Which function gets called in the following code? class Person { public: void print() ; } ; class Student : public Person { public: void print() ; } ; int main() { Person* x = new Student() ; x->print() ; return 0 ; } a. Person::print() b. Student::print() c. void print() ; d. No function gets called, this is a segmentation fault 3
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 04/02/2012.

Page1 / 13

cs12_05spr_002_mt_sol - Last name First name SID(last 4...

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