Homework 6 This homework is intended to help you prepare for the upcoming exam.
ID: 3598774 • Letter: H
Question
Homework 6 This homework is intended to help you prepare for the upcoming exam. We have gone through and picked out several problems from the textbook and come up with some ourselves that we feel are important and answering these questions should help you prepare for the exam Please type up your answers and submit a pdf to collab. If you submit any other file type we will deduct points. Enjoy! Collections Framework Q1 (R15.1) An invoice contains a collection of purchased items. Should that collection be implemented as a list or a set? Explain your answer. GUI and Event Driven Q2 (R20) An airline company requires a form for users to specify preferences for their travel plans. The form collects first and last name, frequent flyer number, preferred seat type, ( window, center, aisle), number of checked bags and dietary restrictions. What types of form fields do you use to create the form? ( Text Field, Text Area, Radio Button, Checkbox, Drop Down Selector, Drop Down Edit) Q3 (R10) What is the difference between an ActionEvent and a MouseEvent? Stacks and Queues Read section 15.6.4 about using a stack to traverse a maze Q4 (R15.25 and R15.26) Write out the order of letters encountered in the maze on page 714 of Big Java using a stack (R15.25) and a queue (R15.26) Exceptions Q5 (R11.8) Why don't you need to declare that your method might throw an IndexOutOfBounds exception? Q6 (R11.10) What happens if an exception does not have a matching catch clause? Algorithms Q7 (Chapter 5 problem 4 from the MSD textbook) Consider the following outline of a program (See book for details). Assuming that n is the problem size, what would be the critical section of this program? Why?Explanation / Answer
Q1.
The list is an ordered collection that maintains insertion order, which means upon displaying the list content it will display the elements in the same order in which they got inserted into the list, whereas Set doesn't maintain any order. Also, a list can contain duplicate elements but Set cannot.
In this case, it is an invoice in which entries are made based on insertion order and may contain duplicates, hence to implement an invoice we should use List.
Q2.
Forms fields should be as following :
First Name - Text Field
Last Name - Text Field
Frequent Fyler Number - Dropdown Edit
Preferred Seat type - Radio button
Number of Checked bags - Dropdown Selector
Dietart Restrictions - TextArea
Q3.
The main difference between action event and mouse event is that the ActionListener executes when the button is clicked whereas, for the MouseListener, you need to focus, hover, or make sure the x and y coordinates are in the right place.
Q6.
If an exception does not have a matching catch clause this kind of exception called the uncaughtException() method of the thread's Thread Group being requested, which ultimately results in the termination of the program in which it is thrown.
Note: As per the Chegg policy only 4 questions are allowed to answer at a time. please post another post for the remaing solutions.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.