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.2.3. Key Methods
This section
Practice test
10 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 method would you use to add a new element to a list?
Hint
Think about how you would append an item to the end.
- 2.
How would you access the first item in a list?
Hint
Remember indexes start at zero.
- 3.
Which method would you use to remove an element from a list?
- add()
- remove()
- get()
Hint
Think about what action is represented by each method.
- 4.
True or False: The get method can retrieve any element in the list.
- True
- False
Hint
Consider the concept of accessing elements by index.
- 5.
Given an ArrayList of integers, write a method to find and replace all occurrences of a value with another value.
Hint
Think about how you'd loop through and access each element.
- 6.
Create a list of your five favorite books, then use the listIterator to print them in reverse order.
Hint
Remember how to initialize the listIterator and its methods.
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
Get your answers marked and your progress tracked
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