created: 01/22/00; revised: 10/04/03, 02/12/06

Quiz on Applet Examples

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.

1. What must be imported to get class JApplet

A.    javax.swing.JApplet

B.    java.util.*

C.    java.Applet


2. What must be imported to get most graphics components?

A.    java.Graphics

B.    java.awt.*

C.    java.util.*

D.    java.*

3. To draw a rectangle filled in with the current color use this method:

A.    drawRect()

B.    fillRect()

C.    drawOval()

D.    fillOval()

4. What is the meaning of final in a declaration: final int width = 350;

A.    width is a loop control variable that will finally reach 350.

B.    width gets the value 350 then never changes.

C.    width is the last variable in the list of variables.

D.    width shadows a similar instance variable.

5. If you are using the Graphics object gr and wish to change the pen color to red, what should you do?

A.    gr.setColor( )

B.    gr.setPen( )

C.    setBackground( )

D.    gr.setRed( )

6. In what order must the vertices be added to a Polygon object?

A.    In clockwise order, starting with the left-most vertex.

B.    In either clockwise or counter clockwise order, going around the polygon, starting with any vertex.

C.    In any order, as long as all vertices are included.

D.    In clockwise order going around the polygon, starting with the top vertex.

7. What method call is used to draw a line from X=20, Y=30 to X=70, Y=50

A.    gr.drawLine( 20, 70, 30, 50 );

B.    gr.drawLine( 20, 30, 70, 50 );

C.    gr.drawLine( 20, 30, 50, 70 );

D.    gr.drawLine( (20, 30), (70, 50) );

8. What HTML tags should begin and end a web page?

A.    <applet>   </applet>

B.    <body>   </body>

C.    <h1>   </h1>

D.    <html>   </html>

9. What method of your applet is called by the browser when it wishes to display it on the monitor?

A.    paint()

B.    drawLine()

C.    setBackground()

D.    setColor()

10. Can the source code for your applet be compiled by the usual javac compiler?

A.    No — because applets have no main()

B.    No — the web browser compiles the code.

C.    Yes — an applet is just another class as far as the compiler is concerned.

D.    Yes — if you are going to run it from the DOS prompt.

The number you got right:       Percent Correct:       Letter Grade:   

Click here If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.