# Past Exam for COSC 102 - Intro to Computing II at Colgate (CU)

## Exam Information

 Material Type: Exam 1 Professor: Staff Class: COSC 102 - Intro to Computing II Subject: Computer Science University: Colgate University Term: Spring 2004 Keywords: AssumptionsCircumstancesFollowing CodePostconditionCode SegmentLargest ValueCorrect AnswersSpring 2004 ExamTime ComplexityPrecondition

## Sample Document Text

COSC 102, Spring, 2004 Exam 1 Name_______________________________ Questions 1-6 are multiple choice and multiple answer. Mark all answers that are correct. There is at least one correct response for each question. (7 points each) 1. Consider the following incomplete declarations within a class. private Map studentGPAMap; // precondition: All values in studentGPAMap are Doubles with value >= 0.0 // postcondition: return the largest value found in studentGPAMap public Double method maxGPA() { Double max = new Double(0.0); // code segment } return max; Which of the following code segments will correctly complete the method maxGPA? (Circle all correct answers.) A. Iterator itr = studentGPAMap.iterator(); while(itr.hasNext()){ Double val = (Double)itr.next(); if(max.compareTo(val) < 0) max = val } B. Iterator itr = studentGPAMap.keySet().iterator(); while(itr.hasNext()){ if(max.compareTo(itr.next()) < 0) max = (Double)itr.next(); } C. Iterator itr = studentGPAMap.keySet().iterator(); while(itr.hasNext()){ Doub...

## Related Documents

Circumstances Exam