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

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

Questions and Exercises: Object-Oriented Concepts

Questions

Use the API documentation for the Java 2 Platform to answer these questions:
  1. The ClickMe applet uses Color.red to set the drawing color to red. What other colors can you get by name like this?
  2. How would you specify other colors, like purple?

Exercises

Now, use what you learned from the javadocs to make the following modifications to the ClickMe(in a .java source file) applet. To compile this program, you also need the Spot.java(in a .java source file) file.


Note:  This is an exercise in reading code, making guesses, and looking up classes and methods in the javadocs. We haven't yet given you any detailed information about how to write Java code and what it all means. But you might be surprised at how much you can intuit from the code. The main point of this exercise is to get you to use the javadocs and to read code. Do not worry if you cannot get your solution to work. Do not worry if your solutions do not match ours. Do compare your solutions to ours so that you can get more experience reading code and perhaps learn more about the API in the Java platform.
  1. Modify the applet to draw a green square instead of a red spot.
  2. Modify the applet to display your name in purple instead of a red spot.
Check your answers.(in the Learning the Java Language trail)

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

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