{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Quiz11 - COMP 1210 Quiz 11 – – Page 1 of 2 Name Lab...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COMP 1210 Quiz 11 – 11/30/2011 – Page 1 of 2 Name: _______________________________ Lab Time: ______________ Multiple Choice Circle the letter in front of the most correct answer to each of the questions below: 1. (10%) Which of the following explicitly demonstrates exception propagation? a. A new type of exception extending a class in the exception class hierarchy b. An exception being thrown to the calling method c. Two or more exceptions happening simultaneously d. Handling an exception in a try-catch statement e. The finally clause being executed in a try-catch statement 2. (10%) If a single exception occurs in a program and is not handled in a try-catch statement, which type of error occurs? a. A compile-time error b. A run-time error c. A logic error d. A style error e. The program compiles and executes with no error 3. (10%) If a checked exception could occur in the connectServer method and it is not handled in the body of the method, then the_____ reserved word must be used when defining connectServer. a. throw b. try c. catch d. throws e. finally Fill in the blank / Code completion 4. (20%) Suppose that xStr is a String obtained from the user via standard input. Add code around the line below so that “Invalid number input!” is printed to standard output if a NumberFormatException is thrown by parseDouble. You can use any variable name for the NumberFormatException. double xLoc = Double.parseDouble(xStr); COMP 1210 Quiz 11 – 11/30/2011 – Page 2 of 2 5. (10%) If a new exception is defined, it must inherit from the ______________ class or one of its descendants. Answer: _________________________ 6. (15% total) Modify the following constructor so that an IllegalArgumentException is thrown if the parameter sent to the method is not greater than or equal to 0. public ItemList(int size) { if (______________) { 5% _____________ new _____________("Size must be at least 0."); } 5% 5% list = new Object[size]; } 7. (15%) Name the three standard I/O streams (5% each): System.__________________ System.__________________ System.__________________ 8. (15%) Name one of the two sorting algorithms discussed during lecture: Answer: _________________________ 9. (15%) Name one of the two searching algorithms discussed during lecture: Answer: _________________________ ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online