DOC PREVIEW
UMD CMSC 132 - Midterm #2 Key

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

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

Unformatted text preview:

CMSC132 Spring 2008Midterm #2 KeyFirst Name: _______________________Last Name: _______________________Student ID: _______________________Discussion TA: ______________________Discussion Time: _____________________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 forthe question (rounded down). If you feel totally lost on a question, you are encouraged to punt rather than waste time writing down an incorrect answer in hopes of getting some partial credit.- Honors section questions only count for credit for students in the honors section.1Grader Use Only:#1 Software Engineering (30 pts)#2 GUI/Inner Classes (10 pts)#3 Threads (15 pts)#4 Graphs (25 pts)#5Trees(20 pts)Honors (10 pts)Problem 1 (30 pts) Software Engineeringa. (1 pt) Regression testing ensures functionality is not lost when software is bought & sold. F b. (1 pt) Pair-Programming is one of the characteristics associated with extreme programming. Tc. (1 pt) Formal methods are mathematically-based techniques used for high-integrity systems. Td. (1 pt) We prefer inheritance over composition when designing a system. Fe. (1 pt) Test coverage measures whether code is executed by some test case. Tf. (1 pt) Omega testing can start once we have completed Alpha and Beta testing. Fg. (1 pt) Good unit tests eliminate the need for integration tests.Fh. (2 pts) The software life cycle is a sequence of essential operations necessary for producing quality software. Name two of those operations. Answer: Any two of Specification, Design, Selection of Algorithms, Coding and Debugging, Testing and Verification, Documentation and Support, Maintenance.i. (2 pt) In code that contains two if statements, what is the maximum number of flow paths through the code?Answer: 4 j. (2 pts): The Unified process model, the waterfall model, and extreme programming are three different software development methodologies. Order these, from most suitable to least suitable, for developing a totally new kind of application where the functionality required by the application isn’t well understood. Answer: Extreme, Unified, Waterfallk. (2 pts): Compare when/how testing is done in extreme programming, compared to the waterfall model.l.Answer: XP – testing done throughout the whole development process; waterfall at the end2m. (15 pts) Draw a UML class diagram for a model of cars and their engines. A car model can have one of two types of engines: conventional (gasoline) engine or a hydrogen-based engine. A hydrogen-based engine has a number of cells and a serial number. A conventional engine has a serial number and a catalytic (device that reduces toxicity of emissions). You don’t need to represent get/set methods or constructors in your diagram.Answer:CarengineSerial#HydrogenCar ConventionalCarcells catalyticCatalyticEngine3Problem 2 (10 pts) GUI/Inner Class1. (1 pt) JFrame and JPanel are considered containers. T2. (1 pt) Inner classes can only access private components of the outer class. F3. (3 pts) Briefly describe the three components associated with Model-View-Controller model?Answer:Model handles data (performs actual work), View lets user see what program is doingController  controls what work the program is doing(1 pt) What is the Event Dispatching Thread?Answer: Thread where we schedule GUI processing4. (4 pts) Rewrite the main method using an inner class named Handler rather than using an anonymous inner class.public class GUIExample {public static void main(String[] args) {javax.swing.SwingUtilities.invokeLater(new Runnable() {public void run() {new GUIExample();}});}}Answer:public class GUIExample {public static class Handler implements Runnable {public void run() {new GUIExample();}}public static void main(String[] args) {javax.swing.SwingUtilities.invokeLater(new Handler());}}4Problem 3 (15 pts) Threads1. (1 pt) A thread (child) created by another thread (parent) will die immediately after the parent dies. F2. (1 pt) If multiple threads are reading a shared field they should use synchronization, even if no other thread is updating the field. F3. (1 pt) Any lock object used to protect a critical section must always be stored in a static field. F4. (1 pt) A thread can only hold a maximum of two locks at a time. F5. (1 pt) If a thread holds a lock on an object x, that prevents other threads from changing any fields of x. F6. (1 pt) We can use a join method call to make a thread wait for another thread to complete execution. T7. (1 pt) Each thread has its own stack but it shares the heap with other threads. T8. (2 pts) Assume t1 and t2 are two thread objects. Circle the ones in which a data race could be possible between threads t1 and t2 (circle one or both, as appropriate; if neither, write NEITHER). Sequence1  t1.start(); t2.start(); t1.join(); t2.join(); Sequence2  t1.start(); t1.join(); t2.start(); t2.join();9. (6 pts) Implement the delayedShutdown method in the following class.public class Shutdown { /** Print msg and shut down JVM */public static void shutdownNow(String msg) {System.out.println(msg);System.exit(1); // cause entire JVM to shut down}/** * Method should create and start a thread so that after sleeping * for the number of seconds provided, the method shutdownNow * is invoked with the supplied msg. * This method invocation should return immediately, not waiting the * for the shutdown to occur. */public static void delayedShutdown(int seconds, String msg) { Answer 1 (implements Runnable)public class Shutdown implements Runnable {private int secs;private String msg;public static void shutdownNow(String msg) {System.out.println(msg);System.exit(1); // cause entire JVM to shut down}public static void delayedShutdown(int seconds, String msg) {Thread t = new Thread(new Shutdown(seconds, msg));t.start();}public Shutdown(int secs, String msg) {this.secs = secs;this.msg = msg;5}public void run() {try


View Full Document

UMD CMSC 132 - Midterm #2 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
Download Midterm #2 Key
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Midterm #2 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 #2 Key 2 2 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?