Lab - Exp - 9 (Declaring and Using Different Java Collections)
Lab - Exp - 9 (Declaring and Using Different Java Collections)
CCS0023L
(Object Oriented Programming)
EXERCISE
9
Declaring and Using Different Java Collections
<STUDENT NAME>
<SECTION>
<DATE>
I. OBJECTIVES:
Cognitive
a) Learn the behavior of the Collections Interface
b) Learn the behavior of the Set Interface
c) Learn the behavior of the List Interface
d) Learn the behavior of the Map Interface
Psychomotor:
a) construct a program using set, list and map interface
b) compile and debug the error of the program
Affective
a) appreciate the concept behind this experiment
A List cares about the index, a Set doesn’t allow duplicates and a Map cares about the
unique identifiers.
1. Create a program that will prompt the user to choose from the menu:
A. Vector
B. TreeSet
C. Hashtable
D. Exit
If the user selects A, ask the user to enter five pet names. Using vector, sort and display
the names in alphabetical order. Then prompt the menu.
If the user selects B, do as if the user selects A but this time apply TreeSet. Output is the same.
The menu will appear afterwards.
If the user selects C, input the following:
PetType:
PetName:
PetColor:
PetAge:
PetSize:
After inputting, together with the above pet info, display the answer using Hashtable. Then
prompt the menu.
1. The following program is supposed to print the string "Blue". Instead, it throws
an error. Why?
import java.util.*;
Topic Collections
Lab Activity No 9
Lab Activity Declaring and Using Different
Java Collections
CLO 2
Program execution (20)
Correct output (20)
Design of output (10)
Design of logic (20)
Standards (20)
Delivery (10)
TOTAL