Java Programming Online Test – Multiple Choice Questions and Answers 1. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized? java.util.HashSet java.util.ArrayList java.util.LinkedHashSet java.util.List 2. Which of the following statements about the hashcode() method are incorrect? The value returned by hashcode() is used in some collection classes to help locate objects. The hashcode() method is required to return a positive int value. The hashcode() method in the String class is the one inherited from Object. Two new empty String objects will produce identical hashcodes 1 and 2 1 and 4 3 and 4 2 and 3 3. Which class or interface defines the wait(), notify(),and notifyAll() methods? Object Thread Runnable Class 4. Which collection class allows you to access its elements by associating a key with an element’s value, and provides synchronization? java.util.SortedMap java.util.TreeMap java.util.Hashtable java.util.TreeSet 5. What is the numerical range of char? -32768 to 32767 0 to 65535 0 to 32767 -256 to 255 6. Which of the following are Java reserved words? run import default implement 2 and 4 3 and 4 2 and 3 1 and 2 7. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability? java.util.Collection java.util.Set java.util.List java.util.Map 8. Which method registers a thread in a thread scheduler? run(); register(); start(); construct(); 9. Which of the following will directly stop the execution of a Thread? wait() exits synchronized code notifyall() notify() 10. Which interface does java.util.Hashtable implement? Java.util.HashTable Java.util.List Java.util.Collection Java.util.Map Loading … Question 1 of 10