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. Collections and Generics
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
5 cards from this lesson. Good the night before a test.
Try these first
- 1.
What is a Collection in Java?
Hint
Consider grouping items together.
- 2.
Name one implementation of the List interface.
Hint
Think of a dynamic-sized collection.
- 3.
What does a List in Java allow?
- Only unique elements
- Duplicates and ordering
- Only primitive types
Hint
Think about sequences and repetitions.
- 4.
True or False: A Set in Java can contain duplicate elements.
- True
- False
Hint
Consider the basic definition of a Set.
- 5.
Given a list of integers, write a Java method that returns a Set of unique values. Discuss its advantages based on your understanding of Sets.
Hint
Consider using HashSet's add() method.
- 6.
Create a generic method that reverses an array of any type. Show how generics improve the flexibility of your code.
Hint
Think about how the method should handle type parameters.
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