★ wanayoo — archive 1999 http://java.sun.com/developer/onlineTraining/new2java/supplements/quizzes/fileproperties.htmlNouvelle recherche | Portail wanayoo
Skip Masthead Links developers.sun.com   » search tips  |  Search:     
The Source for Java Developers
Sun Microsystems
 
 
Quizzes
File Properties Quiz
 
New to Java Programming Center

Test what you learned about Properties in the October issue of Java Technology Fundamentals.

  1. If you add an Integer to a Properties object via the put method of Hashtable as both the key and value [props.put(anInteger, anInteger)], what happens when you try to store the Properties set to a FileOutputStream?
     A. The code won't compile
     B. The toString method of Integer is called to write both the key and value as a String.
     C. A ClassCastException is thrown because the key is not a String
     D. A ClassCastException is thrown because the value is not a String


  2. Which interface does Hashtable not implement?
     A. Cloneable
     B. Comparable
     C. Map
     D. Serializable


  3. Which of the following would sort all the elements in a Properties set, including the defaults?
     A. Create a new TreeMap, passing in the source Properties object to its constructor.
     B. Create a new TreeMap and to the map each key reported by propertyNames and its associated value.
     C. Call the toArray method of Properties and then call Arrays.sort on the result.
     D. Call the sort method of Collections to sort the whole Map (Properties object).


  4. Of which of the following is Properties not a descendent class?
     A. Object
     B. Dictionary
     C. HashMap
     D. Hashtable


  5. What options are available for working with property files that require character encoding in other than the default character set?
     A. Pass the encoding name to the load method of Properties.
     B. Pass the encoding name to the InputStreamReader constructor and then pass that Reader on to the load method of Properties.
     C. Pass the encoding name to the constructor call of the Properties object.
     D. Use the native2ascii tool to convert property files to other character encoding.