Sams Teach Yourself C in 21 Days

(singke) #1
Q When creating a window with components in Java, how do you control the
placement of the various window elements?
AYou do not control the placement of elements directly. Rather you assign a layout
manager to the window, and the layout manager arranges the elements according to
its rules.
Q When you create a graphical element, such as a line or a rectangle, does it
automatically appear on the screen?
ANo. Creating a drawing object is totally separate from displaying it on the screen.
After creating the object, you must use one of the AWT’s drawing methods to actu-
ally display the element.
Q What are the main differences between a Java applet and an application?
AAn applet has no mainmethod; rather execution begins with the initandstart
methods. Also, an applet cannot read or write disk files.

Workshop ............................................................................................................


The Workshop provides quiz questions to help you solidify your understanding of the
material covered, and exercises to provide you with experience in using what you’ve
learned. Answers to the quiz are provided in Appendix F.

Quiz ..............................................................................................................



  1. Does every tryblock need an accompanying catchblock?

  2. Does the BufferedWriterobject’s writemethod automatically start a new line
    when writing text to a file?

  3. What class are all Java applets based on?

  4. When creating a window-based application, what method do you call to make the
    program visible on the screen?

  5. How does a Java application respond to user events?

  6. Can a Java applet have a mainmethod?

  7. What two methods are called, and in what order, when an applet begins execution?

  8. What is the very last method called when an applet terminates?


764 Bonus Day 6

41 448201x-Bonus6 8/13/02 11:23 AM Page 764

Free download pdf