Chapter 38 Programming Exercises

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

created 01/22/00


Chapter 38 Programming Exercises

Exercise 1

Experiment with the red and blue concentric circle applet to enhance the stereo effect. You will need some red/blue 3D vision glasses. If you don't have them, try the next method.

Click here to go back to the main menu.


Exercise 2

Draw the two sets of concentric circles side by side, separated by about six centimeters. Don't draw identical images; draw one set of circles with increasing offset the closer to your eye they are supposed to be. When displayed, look at the left set with your left eye, the right set with your right eye, and try to merge the two images together.

Click here to go back to the main menu.


Exercise 3

Draw 10 complete big circles randomly positioned in the applet. To draw complete circles, test that each randomly generated center is further from the edge than the radius of a circle.

Click here to go back to the main menu.


Exercise 4

Draw 10 complete circles randomly positioned in the applet, with random radii in the range 5 to 25 pixels. Randomly pick each circle's color (use a random int and nested if statements.)

Click here to go back to the main menu.


End of the Exercises