Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Working Applet
Help and Hints
Source Code
Table of Contents
Online Training
shadowSearchFAQFeedback

ChoiceTest

Prerequisites

  • None.
In this exercise, you will write an applet that creates and displays a Choice component.

Perform the following tasks:

  1. Create an applet called ChoiceTest. In the init method, create and add an object called MyChoice that you will create later.
  2. Create a class called MyChoice that extends Choice. In its constructor, add three items: "Chocolate", "Vanilla", and "Strawberry".
  3. Define the method action in MyChoice so that when the user selects an item, it is printed to System.out.
The task numbers above are linked to the step-by-step help page. Also available is a complete solution which meets these requirements.

Related Exercises