The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search

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

## Questions and Exercises: Object-Oriented Concepts

> ### Questions

> > Use the javadocs 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` applet.

> > > 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 pont 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.

> ### Extra Credit Exercises

> > Use the javadocs to find information to help you make these modifications to the `ClickMe` applet.
> > 1. Modify the applet to erase the red spot instead of redrawing the whole applet.
> > 2. Modify the applet to drag the red spot when the mouse is held down.
> >    Hint: For this exercise, start with the result from the previous exercise (erasing the spot rather than redrawing the applet).

> Check your answers.

| Start of Tutorial > Start of Trail > Start of Lesson | Search