Log In Register

Units


Java.util Library - Questions and Answers

 

Practice these Java.util Library under Java Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Java.util Library for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Java.util Library of Java Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge Java Programming specifically Java.util Library.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Java.util Library under Java Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Java.util Library topic of Java Programming:

 

1. Which of these method is used to add an element to the start of a LinkedList object?

Answer: Option D

Explanation:

2. Which of these methods is used to add elements in vector at specific location?

Answer: Option D

Explanation:
addElement() is used to add data in the vector, to obtain the data we use elementAt() and to first and last element we use firstElement() and lastElement() respectively.

3. Which of these method is used to make all elements of an equal to specified value?

Answer: Option B

Explanation:
fill() method assigns a value to all the elements in an array, in other words it fills the array with specified value.

4. Which of these method is used to make a bit zero specified by the index?

Answer: Option D

Explanation:

5.  Which of these class can generate an array which can increase and decrease in size automatically?

Answer: Option A

Explanation:

6. Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?

Answer: Option A

Explanation:
Dictionary, Map & Hashtable all implement Map interface hence all of them uses keys to store value in the object.

7. Which of these method is used to change an element in a LinkedList Object?

Answer: Option C

Explanation:
An element in a LinkedList object can be changed by first using get() to obtain the index or location of that object and the passing that location to method set() along with its new value.

8. Which of these method can be used to increase the capacity of ArrayList object manually?

Answer: Option D

Explanation:
When we add an element, the capacity of ArrayList object increases automatically, but we can increase it manually to specified length x by using function ensureCapacity(x);

9. Which of these methods can be used to delete the last element in a LinkedList object?

Answer: Option C

Explanation:
removeLast() and removeFirst() methods are used to remove elements in end and beginning of a linked list.

10. Which of these class object can be used to form a dynamic array?

Answer: Option D

Explanation:
Vectors are dynamic arrays, it contains many legacy methods that are not part of collection framework, and hence these methods are not present in ArrayList. But both are used to form dynamic arrays.

11. Which of these method is used to reduce the capacity of an ArrayList object?

Answer: Option D

Explanation:
trimTosize() is used to reduce the size of the array that underlines an ArrayList object.

12. Which of these object stores association between keys and values?

Answer: Option B

Explanation:

13. Which of these method of HashSet class is used to add elements to its object?

Answer: Option A

Explanation:

14.  Which of these methods can be used to obtain set of all keys in a map?

Answer: Option D

Explanation:
keySet() methods is used to get a set containing all the keys used in a map. This method provides set view of the keys in the invoking map.

15. Which of these methods can be used to search an element in a list?

Answer: Option D

Explanation:
binaryserach() method uses binary search to find a specified value. This method must be applied to sorted arrays.