|
INTERVIEW QUESTIONS
J2EE
JAVA
DETAILS
Question: How can we use hashset in collection interface?
Answer: This class implements the set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the Null element.
This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important
|
|
|
Category |
Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9127 users |
Added on |
7/16/2011 |
Views |
66651 |
Rate it! |
|
|
Question:
How can we use hashset in collection interface?
Answer:
This class implements the set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the Null element.
This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over this set requires time proportional to the sum of the HashSet instance's size (the number of elements) plus the "capacity" of the backing HashMap instance (the number of buckets). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is difference between java.lang .Class and java.lang.ClassLoader? What is the hierarchy of ClassLoader
|
View Answer
|
|
What is difference between array & arraylist?
|
View Answer
|
|
if interface & abstract class have same methods & abstract class also not contain any implementation for those methods which one you prefer ?
|
View Answer
|
|
How can you load DLL files when your java class is loading first time ?
|
View Answer
|
|
What is difference between string and stringtokenizer?
|
View Answer
|
|
We know that Object class is super class of every class & a class extends only one class. so how is it possible to a class to extend other than Object class?
|
View Answer
|
|
What is JVM Heap Size? How does it affect the performance of the Application?
|
View Answer
|
|
How many JVM could be run on an operating system. if only one then what is the logical reason.
|
View Answer
|
|
What are differences between Enumeration, ArrayList, Hashtable and Collections and Collection?
|
View Answer
|
|
Which class is the super class for all classes in java.lang package?
|
View Answer
|
|
Why the container does not support multiple layout managers
|
View Answer
|
|
How to use JNI in java? and what are Struts and jini?and how to apply native code in java?
|
View Answer
|
|
Can wehave run() method directly without start() method in threads?
|
View Answer
|
|
When programmer using the vector and arrylist? and when ur using linkedlist and hashmap and hashtable?
|
View Answer
|
|
WHEN UR USING ARRAYLIST AND LIKEDLIST AND VECTOR AND HASHMAP AND HASHTABLE?
|
View Answer
|
|
if two overloaded methods are- Test(Object xyz) and test(Customer cust)[Assume Customer is a class with member name of type String].Now if we call test(null), which method will be called? why?
|
View Answer
|
|
How single threaded model works after implementation in class, basically architecture point of view.
|
View Answer
|
|
Is there any difference between Execution Engine and the JIT in java?
|
View Answer
|
|
If we have two public classes in a single java file ,how i have to give the name of the particular java file and how i can compile it?
|
View Answer
|
|
What is the difference between classpath and path variable?
|
View Answer
|