Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
15.5.2.1. HashMap
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
4 cards from this lesson. Good the night before a test.
Try these first
- 1.
What is a HashMap?
Hint
Think about collections that store pairs.
- 2.
Can a HashMap have a null key?
Hint
Consider how many null values a HashMap can store.
- 3.
What type of collection is a HashMap?
- Ordered
- Unordered
- Sorted
Hint
Think about the nature of HashMap organization.
- 4.
True or False: HashMap allows multiple null keys.
- True
- False
Hint
How many null keys can you have in a HashMap?
- 5.
Write a Java program that creates a HashMap to store employee names and IDs, then prints each employee's details using entrySet() method.
Hint
Remember to import java.util.HashMap first!
- 6.
Compare the performance of a HashMap versus a TreeMap for inserting 1000 elements. What observations can you make?
Hint
Set up a timer to measure insertion times.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting