The JavaTM Tutorial
Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Object-Oriented Programming Concepts

Answers to Questions and Exercises: Object-Oriented Concepts

Answers to Questions

You can find the information needed to answer these questions in the API documentation for the Color (in the API reference documentation) class.
  1. Question: The ClickMe applet uses Color.red to set the drawing color to red. What other colors can you get by name like this?
    Answer: black, blue, cyan, dark gray, gray, green, light gray, magenta, orange, pink, white, and yellow.

  2. Question: How would you specify other colors, like purple?
    Answer: Construct a Color object for the color you want. The easiest way to do this is to specify the RGB values for the color you want. For example, purple is Color(0.5, 0.0, 0.5).

Answers to Exercises

To read explanations about the solutions and to run the resulting applets, see Getting Started (in the Learning the Java Language trail).
  1. Exercise: Modify the applet to draw a green square instead of a red spot.
    Answer: Look at our solution, contained in the ClickMeGreen.java (in a .java source file) source file.

  2. Exercise: Modify the applet to display your name in purple instead of a red spot.
    Answer: Look at our solution, contained in the ClickMePurple.java (in a .java source file) source file.

Previous Page Lesson Contents Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.