DOC PREVIEW
UMD CMSC 132 - Midterm #1 Key

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC132 Summer 2006 Midterm 1 Key Grader Use Only 1 2 3 4 5 Total First Name 25 25 20 10 20 100 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 Problem 1 Software Development 25 pts a 4 pts The software life cycle is a sequence of essential operations necessary for producing quality software Mention four of those essential operations 2 Answer Any four from the following group Problem Specification Program design Alg and Data Structures Coding and debugging Testing and Verification Documentation and support Maintenance b 3 pts Describe the unified model of software development Answer In this model we iteratively add incremental improvements In this model the software development is divided into phases iterations where in each phase we have all the essential operations of the software life cycle Each phase is divided into inception Elaboration Construction Transition c 3 pts What are three principles Extreme Programming is based on Answer Any three of the following Small Releases Simple Design Testing Pair Programming 40Hour Week On Site Customer d 2 pts What is encapsulation Answer An extension of abstraction It confines information so it is only visible accessible through an associated external interface e 2 pts What is Clear box testing Answer You are allows to examine the code f 2 pts What is Beta testing Answer Testing that is in the real user environment and using a black box test approach g 2 pts What is Alpha testing Answer Tests components during development and usually uses a clear box test approach h 2 pts What is Regression testing Answer Testing to ensure functionality if not lost or changed Test suites are run periodically after software changes i 3 pts Briefly explain whether we can have a program with an infinite number of flow paths Answer Yes j 2 pts What are the advantages of the Model View Controller Answer Separates data from its appearance provides control over interface promotes better code organization e g you can update the view without accessing model classes 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 3 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 Answer 4 En interface Cd rev String maxmem int Rw len int ms double Ve id int desc String Pl n String max int maxmem int Pl n String max int lan r Rw void toString String Problem 3 Java Programming 20 pts a 3 pts What is the difference between a checked and an unchecked exception Answer You are not required to handle an unchecked exception whereas a check exception must be handle by defining a try catch pair or by throwing the exception throws in method prototype b 4 pts Rewrite the following for loop using the new enhanced for loop ArrayList String c new ArrayList String c add Mary c add Robert c add Raymond for int i 0 i c size i System out println c get i length Answer for String elem c System out println elem length c 6 pts An interface named Manager declares the following method public void distributeSchedules 5 Using anonymous classes replace the comment in the following main with an object that implements the Manager interface The distributeSchedules method should print the message Schedules have been distributed public static void main String args Manager myManager PUT YOUR CODE HERE Answer Manager manager new Manager public void distributeSchedules System out println Schedules have been distributed d 7 pts Modify the following class so we can sort Highway objects by id using the Colletions sort method public class Highway public int id public String name public Highway int id String name this id id this name name Answer public class Highway implements Comparable Highway public int id public String name public Highway int id String name this id id this name name public int compareTo Highway highway if id highway id return 1 else if id highway id return 0 return 1 Problem 4 Writing Test Cases 10 pts 6 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 8 pts 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 Answer assertTrue Utilities linearSearch data assertTrue Utilities linearSearch data assertTrue Utilities linearSearch data assertTrue Utilities linearSearch data assertTrue Utilities linearSearch data b JL 0 PK 2 NO 1 case for element not in the array JL 0 null 1 Are there any assertion s the above code will fail Answer No Problem 5 Design 20 pts For this problem you will provide a design for a system used to maintain information about computers The specifications for the system are Two kinds of computers are possible desktops and laptops A laptop is classified as a portable device All computers are classified as electronic devices and all have at least one USB port Only desktops


View Full Document

UMD CMSC 132 - Midterm #1 Key

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Loading Unlocking...
Login

Join to view Midterm #1 Key and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Midterm #1 Key and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?