Docsity

Summer 2006 CMSC132 Midterm 1 - Software Development and UML, Exams of Computer Science

Toggle sidebar
bg1
CMSC132
Summer 2006
Midterm #1
First Name: _______________________
Last Name: _______________________
Student ID: _______________________
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.
1
Grader Use Only:
#1 (25)
#2 (25)
#3 (20)
#4 (10)
#5 (20)
Total (100)
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Summer 2006 CMSC132 Midterm 1 - Software Development and UML and more Exams Computer Science in PDF only on Docsity!

CMSC

Summer 2006

Midterm

First Name: _______________________

Last Name: _______________________

Student ID: _______________________

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.

Grader Use Only:

Total (100)

Problem 2 UML (25 pts)

Given the following Java code, draw its complete (include fields and method information) UML class diagram. public interface Cd { public int maxmem(); } public class En { public String rev; } public class Rw { public int len; public double ms; } public class Ve { public int id; public String desc; } public class Pl extends Ve implements Cd { private String n; private int max; public int maxmem() { return max; } public Pl(String n, int max) { this.n = n; this.max = max; } public void lan(Rw r) { System.out.println("Processing " + r.len); } public String toString() { return n + "---" + max; } }

DRAW THE DIAGRAM ON THE NEXT PAGE

UML DIAGRAM GOES HERE

YOU CAN USE THE NEXT PAGE TO ANSWER THE ABOVE QUESTIONS

Problem 4 Writing Test Cases (10 pts)

The linearSearch method returns the array index where searchValue appears in the array, or -1 if searchValue is not part of the array. You can assume elements of the array are unique. public static int linearSearch(String[] array, String searchValue) { int searchIndex = -1; for (int i=0; i<array.length; i++) { if (array[i].equals(searchValue)) { searchIndex = i; } } return searchIndex; } A possible JUnit test for this code is the following: public class MyTests extends TestCase { String[] data = new String[]{"JL", "MJ", "PK"}; public void testOne() { assertTrue(Utilities.linearSearch(data, "MJ")==1); } } a. Using the data array provided above, write as many assertions you understand are necessary to verify the correctness of the linearSearch method. You don’t need to provide JUnit test cases; just assertions (e.g., assertTrue(…)). b. Are there any assertion(s) the above code will fail?

YOU CAN USE THE NEXT PAGE FOR YOUR UML