Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Sample Midterm Exam 1 - Object-Oriented Programming II | CMSC 132, Exams of Computer Science

Midterm1Spring2006 Material Type: Exam; Professor: Padua-Perez; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Spring 2007;

Typology: Exams

Pre 2010

Uploaded on 05/20/2008

freakazeud
freakazeud 🇺🇸

15 documents

1 / 11

Related documents


Partial preview of the text

Download Sample Midterm Exam 1 - Object-Oriented Programming II | CMSC 132 and more Exams Computer Science in PDF only on Docsity! CMSC132 Spring 2006 Midterm #1 First Name: _______________________ Last Name: _______________________ Student ID: _______________________ Section time ___________ TA: __________________________ I pledge on my honor that I have not given or received any unauthorized assistance on this examination. Your signature: _____________________________________________________________ General Rules (Read):  This exam is closed book and closed notes.  If you have a question, please raise your hand.  Total point value is 100 points.  The short answer questions are not essay questions. Strive to answer them in 1 or 2 sentences. Longer answers are not necessary and are discouraged.  WRITE NEATLY. If we cannot understand your answer, we will not grade it (i.e., 0 credit).  PUNT RULE: For any question, you may write PUNT, and you will get ¼ of the points for the question (rounded down). If you feel totally lost on a question, you are encouraged to punt rather than waste time writing down a bunch of vaguely related verbiage in hopes of getting some partial credit.  Honors section questions only count for credit for students in the honors section. 1 Grader Use Only: #1 (25) #2 (25) #3 (25) #4 (13) #5 (12) Total (100) Honors (10) Problem 1 Software Development (25 pts) a. (5 pts) What is the primary difference between the waterfall model of software development and the unified model. b. (5 pts) Explain why good code coverage is important. c. (5 pts) Give an example of a specific bug that would not be addressed or helped by having good code coverage. d. (5 pts) What does Extreme Programming say about testing and why is it an important part of Extreme Programming? e. (5 pts) What are the advantages using the Model View Controller design pattern? 2 b. (12 pts) Consider the UML diagram below: Give minimal Java class declarations for classes A-F, that you can infer from this diagram. Don’t give any methods, just the class declaration header and declare what fields are indicated by this diagram. 5 Problem 3 Java Programming (25 pts) a. (3 pts) What is the difference between a checked and an unchecked exception? b. (3 pts) Rewrite the following for loop using the new enhanced for loop. String[] names = {"Pete", "Rose", "Mary"}; for (int i=0; i < names.length; i++) System.out.println(i); c. (3 pts) What would be a typical use of the try { … } finally { … } construct? What would go into the try and finally clauses? 6 d. (8 pts) Give an implementation of the iterator() method of IntegerRange that uses an anonymous inner class: public class IntegerRange implements Iterable<Integer> { final int min,max; public IntegerRange(int min, int max) { this.min = min; this.max = max; } public Iterator<Integer> iterator() { … } } Calling remove on an IntegerRange iterator should throw an UnsupportedOperationException. A class that implements Iterator<Integer> needs to implement the following public methods: boolean hasNext(); Integer next(); void remove(); Give the body of the iterator() method below: 7 Assume we wish to test the following two methods: public class Util { /** * Return the minimum value (using the standard < ordering) * of the arguments */ public static int min(int a, int b, int c) { ... } /** * Return the index of the first location in a that contains * the same value as x. If x does not occur in x, return -1. */ public static int indexOf(int a[], int x) { ... } } Write a set of test cases to test each of these methods. Give each test case as an expression that should evaluate to true; you don’t need to worry about creating jUnit tests, and don’t use loops or other coding techniques to make a large number of calls. Just give a reasonable number of expressions to use to test these methods. Note that you can use, for example, new int[] {5,3} in an expression to create an int array of length 2 initialized to contain 5 and 3. 10 Honors Section Problem (10 pts) Lots of problems have been proven to be undecidable: not only the halting problems, but the book described other undecidable problems such as the tiling problem and domino snakes on the half plane. a) What general approach/technique might you use to show that a problem is undecidable? b) Say you are working at a company on a project, and the feature set for your project includes solving a problem that are you able to show is undecidable. What are the practical implications of this? 11
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved