Quiz10_43key.doc

advertisement
COP 2551
Name:____________________________________
Chapters 5-8 Graphics & Chapter 11 Recursion
8/3/2004
For multiple choice questions, circle the letter of the best answer.
1.
When you click a mouse, which of the following events is/are generated?
a.
b.
c.
d.
2.
A dialog box is used to
a.
b.
c.
d.
3.
Create a listener object.
Add the listener object to the graphical component that generates the event.
Both a. and b. above. <===
None of the above.
Which of the following is/are true of listener objects?
a.
b.
c.
d.
5.
convey information.
confirm an action.
allow the user to enter some information.
any of the above. <===
To respond to an event, you must:
a.
b.
c.
d.
4.
Mouse pressed.
Mouse released.
Mouse clicked
All of the above. <===
A component can have multiple listeners for various event categories.
A single listener object can serve multiple components.
Both a. and b. above. <===
Neither a. nor b. above.
Which of the following is not useful by itself?
a.
b.
c.
d.
A single check box.
A single radio button. <===
Neither a. nor b. above is useful by itself.
Either a. or b. above can be used by itself.
6.
The first two arguments of a Polygon constructor are:
An integer array of the x-coordinates for the points on the polygon.
An integer array of the y-coordinates for the points on the polygon.
7.
The last argument of a Polygon constructor is:
The number of points on the polygon.
8.
You can draw a filled polygon by using the fillPolyline() method and connecting
the last line to the first line.
a.
b.
9.
True
False <===
The timer class generates ______________________ events at regular intervals.
a.
b.
c.
d.
10.
timer
action
<===
mouse
keyboard
The recursive definition of N! (N factorial) is
1! = 1
N! = N * (N-1) !
The first part of the definition is called the
a.
b.
c.
d.
root
terminator
recursive case
base case <===
Bonus Question (5 points)
Using recursion, complete the following method that returns the sum of 1 to N.
public int sum (int N)
{
int result;
if (N == 1)
result = 1;
else
result = num + sum(num - 1);
return result;
} // end sum( ) method
Bonus Question (5 points)
The original Java package used to create Applets was the Abstract Windowing
Toolkit (AWT). What is the name of the new package that inherits from and extends the
AWT package?
javax.swing or just swing
Download