created: 01/22/00; revised: 10/04/03, 02/12/06, 07/02/16
Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. To grade the quiz, click on the button at the bottom.
1. Where is the point (0, 0) located on a JPanel ?
(0, 0)
JPanel
2. What must be imported to get most graphics components?
import
3. To draw a rectangle filled with the current color use this method:
4. What is the meaning of final in a declaration: final int width = 350;
final
final int width = 350;
width
5. If you are using the Graphics object gr and wish to change the pen color to red, what should you do?
Graphics
gr
gr.setColor( Color.RED )
gr.setPen( Color.RED )
setBackground( Color.RED )
gr.setRed( )
6. In what order must the vertices be added to a Polygon object?
Polygon
7. What method call is used to draw a line from X=20, Y=30 to X=70, Y=50
gr.drawLine( 20, 70, 30, 50 );
gr.drawLine( (20, 30), (70, 50) );
gr.drawLine( 20, 30, 50, 70 );
gr.drawLine( 20, 30, 70, 50 );
8. What method of JPanel is called when the system needs to redraw the panel?
paint()
draw()
paintPanel()
paintComponent()
9. Say that a JPanel was originally made to be width pixels across, but now the user has changed the display so the panel is a new size. Which of the following should be used to multiply the X coordinates in the new drawing?
double scale = ((double)getWidth())/width;
double scale = width/getWidth();
double scale = ((double)width)/getWidth();
int scale = width/getWidth();
10. Your program has a reference to a Polygon object in the variable poly. How do you put an additional point in the list of vertices for that polygon?
poly
poly.point(x, y)
poly.add(x, y)
poly.addPoint(y, x)
poly.addPoint(x, y)
The number you got right: Percent Correct: Letter Grade: