Question 36
Given: What is the result?
- The compilation fails.
- [0). D, | 1). i, | 2). a]
- [). o, | 1). a, | 2).]
- [0). o, | 1). i, | 2). r]
- ArrayIndexOutOfBounds Exception is thrown at runtime.
Question 37
Given: What is the result?
- An exception is thrown at runtime.
- -3
- -2
- The compilation fails.
Question 38
Given the code fragment: You must make the count variable thread safe. Which two modifications meet your requirement? (Choose two.)
- replace line 2 with public static synchronized void main(String[] args) {
- replace line 1 with private volatile int count = 0;
- replace line 3 with synchronized(test) { test.count++; }
- replace line 1 with private AtomicInteger count = new AtomicInteger(0); and replace line 3 with test.count.incrementAndGet();
- replace line 3 with synchronized(test.count) { test.count++; }
Question 39
Given the code fragment: Which action enables Computator class to compile?
- change Line 1 to add throws NumberFormatException
- change Line 3 to Double sum = 0.0;
- change Line 5 to List<Double> numbers = List.of(5, 4, 6, 3, 7, 2, 8, 1, 9);
- change Line 2 to public Double sum ( C collection) {
- change Line 4 to for (Double n : collection) {
Question 40
Given the code fragment: What is the result?
- The compilation fails due to an error in line 2.
- 201
- de
- 203
- The compilation fails due to an error in line 3.
- The compilation fails due to an error in line 1.