C S C  3 6 5             E X A M    # 1                Name:________________________

Fall 2002

 

 

(10 Pts.) 1.

What role does the magnetic disk play in external storage? What characteristic(s) in the way multi-platter hard disk work make them suitable for random access to data.

 

 

 

 

 

 

 

 

 

 

 

 

 

(20 Pts.) 2.

Two techniques for maintaining File Allocation Tables were discussed in

class, extents and bitmaps. 

 

What role do FATs play in file systems?

 

 

 

 

 

 

 

 

 

 

 

Briefly, describe how each (extents/bitmaps) work.

 

 

 

 

 

 

 

 

 

 

(30 Pts.) 3.

The following code segment is from the dictionary2.java which introduced Maps

and their treeMap implementation. Assume that s is bound to a TreeMap and has been populated with word/meanings from a data file.  Don't worry about exceptions.

 

     BufferedReader inp   = new BufferedReader(new InputStreamReader(System.in));

 

    Iterator i=s.entrySet().iterator();

    while(i.hasNext()) {

      Map.Entry d = (Map.Entry)i.next();

      if (((String)d.getKey()).length()<8)

        System.out.println(d.getKey()+"\t\t"+d.getValue());

      else

        System.out.println(d.getKey()+"\t"+d.getValue());

    }

 

 

a) Change the above code segment so that the user is first prompted for a partial-word and the partial-word entered by the user is used to locate and print all word/meanings in s where the word has the partial-word in it. Keep in mind that the partial-word entered by the user may be larger than a word in our TreeMap.  Ex. If the user types the letter in, all words that have the substring "in" will be picked and displayed along with their meaning. You may want to use the indexOf(str) method from the String class in identifying the right words.

 

 

 

 

 

 

 

b) Rewrite the portions of the code for a) so that all word/meanings where the partial-word entered by the user is found in the meaning instead of the word.

 

 

 

 

 

 

 

c) Write a code segment that would prompt the user for a meaning and displays either the message "in Map" or "Not in Map".  Use the Boolean method containsValue(Object) from the Map interface.


(20 Pts.) 4.

In an application assume that we have a Map m, a JButton d, a JtextField k, and a JTextField v.  Add an ActionListener to d.  The actionPerformed() method in this listener sets  v to the value in Map m associated the key that has been typed into the text field k.   If string in k is not found, v is set to "key not found".  You will need the get(Object) method from the Map interface.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(20 Pts.) 5.

Give a brief description of each of the following Java API classes/Interfaces:

 

        a) ButtonGroup 

 

 

 

 

        b) JScrollPane

 

 

 

 

        c) Set

 

 

 

 

        d) DefaultMutableTreeNode