Professional Documents
Culture Documents
Ans.
A Choice is displayed in a compact form that requires you to pull it down to see
the list of available choices. Only one item may be selected from a Choice. Choice
is the act of picking or deciding between two or more possibilities. Only one item
may be selected from a choice.
A List may be displayed in such a way that several List items are visible. A List
supports the selection of one or more List items. A list is any enumeration of a set
of items. A List supports the selection of one or more list items.
Ans.
1) The getSelectedItem() method returns the label of the selected item. The
label is the string used in the add() or addItem() call. If nothing is selected in
the List, getSelectedItem() returns null. The return value is also null if List is
in multiselect mode and multiple items are selected.
import java.applet.*;
L1.add("Europe");
L1.add("Asia");
L1.add("North America");
L1.add("Australia");
L2.add("India");
L2.add("England");
L2.add("USA");
L2.add("Australia");
c1.add("Maharashra");
c1.add("Karnataka");
c1.add("Goa");
c2.add("Mumbai");
c2.add("Bangalore");
c2.add("Panaji");
c2.add("Pune");
c2.add("Mangalore");
add(lb);
add(L1);
add(L2);
add(c1);
add(c2);
/*<applet code="listandchoice"width="500"height="500">
</applet>*/
OUTPUT: