CMSC132 Fall 2007Midterm #2First Name: ______________________Last Name: ______________________Student ID: ______________________Discussion Section Time: __________ Discussion Section TA Name: ____________________ (-5 points if time is blank or incorrect)I pledge on my honor that I have not given or received any unauthorized assistance on this examination.Your signature: _____________________________________________________________General Rules:- This exam is closed book and closed notes.- If you have a question, please raise your hand.- Answer True/False questions by circling the T or F at the end of the question.Note: +1 point if correct, -1 point if incorrect, 0 point if no answer given- Answer fill-in-the-blank questions with 1 or 2 words.Note: Longer answers are not necessary and will be penalized.- Answer essay questions concisely using 1 or 2 sentences. Note: Longer answers are not necessary and will be penalized.- WRITE NEATLY. Unreadable answers will not be graded (i.e., 0 points).- Honors section questions only count for credit for students in the honors section.1Grader Use Only:#1 Software Development & Testing (17)#2 Object Oriented Programming (12)#3 Object-Oriented Design (UML) (15)#4 Threads & Synchronization (11)#5 GUIs & Event-Driven Programming (6)#6 Heaps (9)#7 Huffman Trees (6)#8 Graphs (14)#9 Binary Trees & Recursion (10)Total (100)Honors (16)1. (17 pts) Software Development & Testinga. Software is expensive to produce due to poor computer science instruction T or Fb. Software is expensive to produce due to lack of good programming languages T or F c. Commonly used software can require millions of source lines of code T or Fd. Maintenance is considered a component of the software life cycle T or Fe. The goal of program design is to select the algorithms and data structures used T or Ff. Software process models are codified sets of practices for software development T or Fg. The Waterfall model begins a new step only when the previous step is complete T or Fh. The Waterfall model uses software prototypes to assess progress T or Fi. The Waterfall model is more appropriate for small software projects T or Fj. The Iterative model emphasizes the ability to adapt to changes T or Fk. The Agile model divides software development into 4 major phases T or Fl. Pair programming is a practice associated with Extreme Programming T or Fm. Formal methods are mathematically-based techniques used for high-integrity systems T or Fn. Empirical testing will find up to 90% of run-time errors in a program T or Fo. Integration testing tests individual methods to ensure their integrity T or Fp. Regression testing ensures functionality is not lost when software is bought & sold T or Fq. Test coverage measures whether code is executed by some test case T or F2. (12 pts) Object Oriented Programming (OOP) a. Abstraction provides a high-level model of a physical entity T or Fb. Encapsulation makes code modification easier but reduces code reuse T or Fc. Improvements in compiler technology help make OO Programming more usable T or Fd. Objects in OO systems posses state, behavior, and quantity T or Fe. Classes in OO programming provide types for objects T or F f. Inheritance describes a relationship between related classes T or Fg. Inheritance does not affect code reuse in OO systems T or Fh. Specification is a form of inheritance implemented using abstract methods in Java T or Fi. Limitation is a form of inheritance implemented using method overriding in Java T or Fj. Java lacks multiple inheritance but can simulate it via interfaces T or Fk. Nouns in a problem statement usually become methods in OO code T or Fl. In OO systems invoking an object’s method is equivalent to sending the object a message T or F23. (15 pts) Object-Oriented Design Given the following problem description, produce an object-oriented solution. Include as manydetails as possible. Draw a UML class diagram (you may write code for Java classes if you don'tknow UML, but will lose points if you do so). Use features of UML described in lecture.You must write a program to keep track of sandwiches ordered by students in a school cafeteria.Sandwich ingredients include slices of bread, cheese, ham, and chicken. Each ingredient has its owncost. The cafeteria offers veggie and non-veggie sandwiches. Veggies sandwiches are made fromslices of cheese. Non-veggie sandwiches are made from slices of ham or chicken. All sandwichesare made using 2 slices of bread. Students may order multiple sandwiches at a time. Students mayalso request 1 extra slice of ham or chicken on their non-veggie sandwich (but cannot mix ham andchicken). Some students are vegetarians and will only order veggie sandwiches. Your programshould track the following: number and type of sandwiches ordered by each student, cost of eachsandwich, total cost for each student, total cost of sandwiches for vegetarian students, total cost ofsandwiches for all students, and the amount of each sandwich ingredients used by the cafeteria.34. (11 pts) Threads & Synchronizationa. Each thread sequentially execute programs as streams of instructions in memory T or Fb. Each thread has its own address space containing variables & data T or Fc. Multithreaded code may be simpler than non-multithreaded code T or Fd. Two scheduling approaches are preemptive and non-preemptive T or Fe. The preferred approach for creating a threaded class is by extending the Thread class T or Ff. The join( ) method is used by Java threads to wait for other threads to terminate T or Fg. A thread can acquire only one lock at a time T or Fh. A lock can be acquired by only one thread at a time T or Fi. (3 pts) The class MyTask implements the Runnable interface. Define and start one thread (myT below) using the MyTask class. You can assume the MyTask has a default constructor. Thread myT = 5. (6 pts) GUIs, Event-Driven Programming, and Java Support for GUIsa. In the software model for GUI design, the view component performs the actual work T or Fb. In Java the JTable class represents a part of the view component T or Fc. An inner class can access all the methods and instance variables of the outer class T or Fd. (3 pts) In Java, the ActionListener interface requires the method void actionPerformed(ActionEvent e) be implemented. Create an anonymous inner class implementing the ActionListener interface for the following Java
View Full Document