AllRounder.ai
Chapters in this course

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.

Enrol free

15.5.1. Map Interface

  • This section

    Practice test

    11 questions on this section. Wrong answers show you what to read again.

    Sign up to take it
  • Whole chapter

    Revision test

    Mixed questions from across the chapter. Your answers get marked.

    Sign up to take it
  • Quick

    Flashcard drill

    4 cards from this lesson. Good the night before a test.

Try these first

  1. 1.

    What does the put method do in a Map?

    Hint

    Think about how you would add an item to a list.

  2. 2.

    True or False: A Map can have duplicate keys.

    Hint

    Consider if you can have two identical names in a contact list.

  3. 3.

    Which of the following methods adds a key-value pair to a Map?

    • get()
    • put()
    • remove()
    Hint

    Consider which option sounds like it relates to 'adding'.

  4. 4.

    True or False: A TreeMap automatically sorts keys.

    • True
    • False
    Hint

    Think about how trees grow: do they follow an order?

  5. 5.

    Create a method that counts the number of occurrences of each character in a string. Use a HashMap for this solution.

    Hint

    Think about how you can check if a character already exists in your Map.

  6. 6.

    Implement a contact manager using a LinkedHashMap where you can add, find, and update contacts based on unique names.

    Hint

    Consider what happens when you want to look for a name: does order matter?

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 free

Quiz

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 free

Challenge 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