Вы находитесь на странице: 1из 3

Computer Science Review Questions Event Driven Programming in Java (Review Question Set 5)

1. What is event-driven programming? 2. How is delegation-based event handling better than traditional, procedural event-handling? Explain. 3. What is an Interface class? Why does Java have classes like this for us the client programmers? 4. What are the three main concepts in event-driven programming? Event sources, event listeners, event handlers. Describe them. And discuss how event handling can be achieved using these three concepts. Can you draw a diagram to show this? 5. What is a prototype method? Provide one example. Why does a client programmer need to use "implements" when using, say, the ActionListener class? What are the "impositions" on a client programmer that come with "implements"? ==============================================================================

Exception Handling (Review Question Set 6)


1. What is Exception handling? What is it for? 2. It has been said that "Exception handling allows the class/method designer to tell us the client programmers that we have misused their class/method." Explain. 3. What is the difference in terms of the objectives for their use between exceptions and assertions? 4. What are three different ways of throwing an exception? Describe. 5. Write a SINGLE method that is an exception thrower, a catcher, and a propagator. 6. What is "finally" for in the "try-catch" block? Give a scenario where it is needed where a statement right after the try-catch block is not able to accomplish. 7. When a try-catch block has several "catches", how should the different exceptions to be caught be arranged? Why? 8. In some scenarios, one might want to propagate all exceptions to a single method or class. Why? Why not? 9. What are checked exceptions and unchecked (runtime) exceptions? Why does

Java distinguish these two exceptions? 10. What are some examples of checked exceptions? What are some examples of unchecked exceptions? ==============================================================================

Arrays, Vectors, and More (Review Question Set 7)


1. How to declare, create, and manipulate an array? 2. Why is an array useful? How? Can you give an example? 3. What is an array of arrays? Same as a 2D array? 4. What is the danger of using .length of an array in accessing the content of an array? What is fixed-size array declaration? 5. How should one manage an array? (Hint: counter, addItem(), removeItem()) How does one keep the "counter" well-maintained? How does one implement the addItem() method? the removeItem() method? 6. Identify the pros and cons of array, vector, and arraylist. 7. When passing an array to a method, is it always passed by "reference"? 8. When passing individual array elements to a method, is it always passed by value? Examples? 9. How does one perform "swapping" of two array elements? 10. If a class has an array as a data member, what other data member should it have, and how should the array be "prepared" for the class? ==============================================================================

Heaps O Fun (Review Question Set 8)


1. Describe each algorithm completely and clearly. From how to start, how to proceed to the next pass, and how to stop. 2. If given a list of numbers, will you be able to tell me the list will look like after N passes? For example, given the following list of numbers: 4, 5, 10, 3, 1, 2, 7, 6, 8, 0

Assuming sorting in ascending order: What does the list look like after 4 passes of insertion sort? What does the list look like after 4 passes of exchange sort? What does the list look like after 4 passes of selection sort? Then by looking at the partially sorted lists of these three, can you recognize interesting differences among the three algorithms? For example, if say, Alibaba is in a hurry, and would like to be able to announce the largest number as soon as possible, the second largest number as soon as possible after that, etc., which algorithm would be the MOST appropriate for Alibaba to use? 3. What is heapsort? Explain the algorithm of heapsort. a. What is a heap? b. What are the two key phases? c. Under each phase, what are the steps? d. Can you describe the algorithm from beginning to the end (precisely so that others can implement it without any ambiguity)? 4. Why is heapsort faster than basic sorting algorithms? 5. In terms of complexity, what are the Big-O values for linear search, binary search, basic sorts, and heapsort? 6. How does one implement in-place selection sort? in-place heapsort? 7. How does one represent a binary tree like a heap in an array?

Вам также может понравиться