

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A practice quiz for csc 335 spring 2007 class. It includes questions on java interfaces, modeling an online bookstore system, collections, and guis and events.
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


public interface Comparable
String input = "momma"; java.util.Map<Character, Integer> tm = new java.util.TreeMap<Character, Integer>(); for (int index = 0; index < input.length(); index++) { char key = input.charAt(index); // containsKey returns true if the key already exists if ( tm .containsKey(key)) { Integer count = tm .get(key); count = count + 1; tm .put(key, count); } else { tm .put(key, 1); } } Set
// Assume all imports exist public class NumberFrame extends JFrame { public static void main(String[] args) { new NumberFrame().setVisible(true); } private JTextField myField = new JTextField(); private JLabel myLabel = new JLabel("Nothing Yet...", JLabel.CENTER); JLabel prompt = new JLabel("Enter a number below"); // initialize the JFrame public NumberFrame() { setUpLayout(); setUpListeners(); } private void setUpListeners() { NumberListener listener = new NumberListener(); myField.addActionListener(listener); } private void setUpLayout() { setTitle("Numbers"); setSize(180, 110);