Oracle
1Z0-805 · Question #30
1Z0-805 Question #30: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-805 to reveal the answer and full explanation for question #30. The question stem and answer options stay visible for context.
Question
Given: public class MyGrades { private final List<Integer> myGrades = new ArrayList<Integer>(); private final ReadWriteLock rwlock = new ReentrantReadWriteLock(); public void addGrade(Integer grade) { /* lock and modify */ } public void averageGrades() { // acquire _______ lock Line ** double sum = 0; int i = 0; Oracle 1Z0-805 Exam for (i = 0; i < myGrades.size(); i++) { sum += myGrades.get(i); } // release __________ lock Line *** System.out.println("The average is: " + sum/(i+1)); } } Which pair's statements should you insert at line ** and line *** (respectively) to acquire and release the most appropriate lock?
Options
- Arwlock.readLock().acquire();
- Brwlock.readLock().lock();
- Crwlock.getLock().acquire();
- Drwlock.getLock().lock();
- Erwlock.WriteLock().acquire();
- Frwlock.writeLock().lock();
Unlock 1Z0-805 to see the answer
You've previewed enough free 1Z0-805 questions. Unlock 1Z0-805 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.