About Question enthuware.ocajp.i.v7.2.925 :
Posted: Thu Aug 30, 2012 1:18 am
Hello!
It seems there's an error in the Enthware JA+ V7 test - it's in the Q18 of LastDayExam:
Given:
import java.util.*;
public class TestClass {
public static void main(String[] args) throws Exception {
ArrayList<Double> al = new ArrayList<>();
//INSERT CODE HERE
}
}
What can be inserted in the above code?
you have to select 3 options:
1. al.add(111);
2. System.out.println(al.indexOf(1.0));
3. System.out.println(al.contains("string"));
4. Double d = al.get(al.length);
5. al.notifyAll();
The corrent answers (by your version) are 2, 3 and 5.
But it seems to me 5 is not suited here.
The program will compile with line at 5 inserted, but it will throw IllegalMonitorStateException, because notyfyAll() method should be called within a synchronized context.
In order to be the 5 option correct the answer should be something like:
What can be inserted in the above code, so it will compile without a problem?
Currently, the question is too vague to give a certain answer.
It seems there's an error in the Enthware JA+ V7 test - it's in the Q18 of LastDayExam:
Given:
import java.util.*;
public class TestClass {
public static void main(String[] args) throws Exception {
ArrayList<Double> al = new ArrayList<>();
//INSERT CODE HERE
}
}
What can be inserted in the above code?
you have to select 3 options:
1. al.add(111);
2. System.out.println(al.indexOf(1.0));
3. System.out.println(al.contains("string"));
4. Double d = al.get(al.length);
5. al.notifyAll();
The corrent answers (by your version) are 2, 3 and 5.
But it seems to me 5 is not suited here.
The program will compile with line at 5 inserted, but it will throw IllegalMonitorStateException, because notyfyAll() method should be called within a synchronized context.
In order to be the 5 option correct the answer should be something like:
What can be inserted in the above code, so it will compile without a problem?
Currently, the question is too vague to give a certain answer.