ptg7068951
248 HOUR 17:Creating Interactive Web Programs
Quiz
- What type of argument is used with the paint()method?
A. AGraphicsobject
B. AGraphics2Dobject
C. None - Which method is handled right before an applet finishes running?
A. decline()
B. destroy()
C. defenestrate() - Why can’t all variables needed in an applet be created inside the
init()method?
A. The scope of the variables would be limited to the method only.
B. Federal legislation prohibits it.
C. They can be created there without any problems.
Answers
- A.TheGraphicsobject keeps track of the behavior and attributes need-
ed to display things on-screen in the applet window. You might create a
Graphics2Dobject inside the method,but it isn’t sent as an argument. - B.Thedestroy()method can be used to free up resources used by
the applet. - A.Variables that are used in more than one method of a class should be
created right after the class statement but before any methods begin.
Activities
Yo u c a n a p p l y y o u r a p p l e t p r o g r a m m i n g k n o w l e d g e w i t h t h e f o l l o w i n g a c t i v i t i e s :
. Write an applet in which the text that is displayed moves each time the
applet window is repainted.
. Install the Java Plug-in with your preferred browser and try the applets
at http://www.javaonthebrain.com.
To s e e J av a p r o g r a m s t h a t i m p l e m e n t t h e s e a c t i v i t i e s ,visit the book’s website
at http://www.java24hours.com.