DOC PREVIEW
UMD CMSC 132 - Quiz 1 Worksheet

This preview shows page 1 out of 2 pages.

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

Unformatted text preview:

CMSC 132 Quiz 1 Worksheet The first quiz for the course will be on Wed, Feb 13. The following list provides more information about the quiz: - The quiz will be a written quiz (no computer). - Closed book, closed notes quiz. - Answers must be neat and legible. We recommend that you use pencil and eraser. The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with the TA or instructor during office hours. Exercises 1. What is encapsulation? How does it relate to abstraction? 2. What is the difference between procedural abstraction and data abstraction? 3. Does 100% test coverage imply the code being tested has no errors? Briefly explain. 4. What is the difference between a checked and an unchecked exception? 5. The method Integer.parseInt throws the NumberFormatException if the string parameter does not represent an integer value. Write a method that keeps asking the user for an integer as long as an invalid value is provided. You should catch the NumberFormatException and add any code needed to keep asking the user for a value. 6. Define an enumerate type named Day that represents the days of the week. Using the enhanced for loop construct, write a code fragment that prints all the days of the week. 7. Is the following code fragment legal? Briefly explain. ArrayList<Boolean> L1 = new ArrayList<Boolean>(); ArrayList<Object> L2 = L1; 8. The PrinterJob class is defined as follows: public class PrinterJob { private int id; private int size; public PrinterJob(int id, int size) { this.id = id; this.size = size; } public int getId() { return id; } public int getSize() { return size; } public String toString() { return "Id: " + id + " Size: " + size; } public int hashCode() { return id; } }a. Add a new private field “jobType” as an enumerated type with the values COLOR and BW . b. Add an equals method that overrides the Object class equals method. c. Modify the class so it implements the Comparable interface, allowing you to compare PrinterJob objects based on their id. d. Implement a comparator class named sizeComparator that allow us to compare PrinterJob objects based on their


View Full Document

UMD CMSC 132 - Quiz 1 Worksheet

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 Quiz 1 Worksheet
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 Quiz 1 Worksheet 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 Quiz 1 Worksheet 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?