Question 1
Which of the following properties is essential for a good hash function?
1
It should generate the same hash for different inputs
2
It should distribute keys uniformly
3
It must produce only prime numbers
4
It must be slow to compute
Question 2
What is a "collision" in hashing?
1
When two different inputs produce the same hash value
2
When two hash functions produce the same output
3
When a hash function fails to generate a unique key
4
When a hash table runs out of space
Question 3
Which of the following is NOT a collision resolution technique?
1
Double Hashing
2
Separate Chaining
3
Quick Sorting
4
Linear Probing
Question 4
In open addressing, which of the following techniques involves checking the next available slot sequentially?
1
Double Hashing
2
Quadratic Probing
3
Linear Probing
4
Separate Chaining
Question 5
Which hash function is commonly used for cryptographic applications?
1
MD5
2
SHA-256
3
CRC32
4
All of the above
Question 6
Which of the following is NOT a property of a cryptographic hash function?
1
Deterministic output
2
Fast reversibility
3
Pre-image resistance
4
Avalanche effect
Question 7
What is the best hashing function characteristic for a HashMap?
1
It should always return the same value.
2
It should minimize collisions and distribute keys uniformly.
3
It should work only for numbers.
4
It should generate the same hash for similar values.
Question 8
What is the impact of using a poor hash function in a HashMap?
1
Faster lookup times
2
More collisions, leading to performance degradation
3
The HashMap will throw an exception
4
Increased memory consumption
Question 9
What is the recommended load factor for optimal performance in a Java HashMap?
1
0.7
2
1
3
0.9
4
0.75
Question 10
What happens if two different keys have the same hash code in a HashMap?
1
The HashMap throws an exception.
2
Both key-value pairs are stored in the same bucket using chaining or tree-based storage.
3
The second key-value pair replaces the first.
4
The keys are ignored.
Question 11
Which of the following statements is true about Java HashMap’s key lookup process?
1
The key lookup is always O(1).
2
HashMap checks hashCode() first, then uses equals() to confirm key identity.
3
HashMap uses a binary search algorithm for lookups.
4
HashMap sorts keys before performing lookup.
Question 12
What is the main advantage of using a perfect hash function?
1
It allows duplicate keys in HashMap.
2
It reduces memory usage significantly.
3
It ensures no collisions occur.
4
It automatically resizes the HashMap.
Question 13
Which technique is used in distributed key-value stores to distribute keys across multiple nodes efficiently?
1
Hash Code Modulo
2
Bloom Filters
3
Consistent Hashing
4
Chaining
Question 14
What is "load factor" in a hash table?
1
The maximum number of elements allowed in a hash table
2
The time taken to insert an element
3
The percentage of non-empty slots in a hash table
4
The ratio of occupied slots to the total capacity