Koofers

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:
  • Assumptions
  • Circumstances
  • Following Code
  • Postcondition
  • Code Segment
  • Largest Value
  • Correct Answers
  • Spring 2004 Exam
  • Time Complexity
  • Precondition
Login / Sign Up to View Document
Preview Page 1Preview Page 2Preview Page 3Preview Page 4Preview Page 5Preview Page 6

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
155, "/var/app/current/tmp/"