Accenture Accenture Primer Practice Question
class TestMain{ public static void main (String[] args) { Map<Tasks, String> m= new HashMap<Tasks, String>();Answer options
A
Tasks t1 = new Tasks("Jan");
B
Tasks t2 = new Tasks("Jan");
C
Tasks t3 = new Tasks("Apr");
D
put(t1,"Design");
E
put(t2,"Code");
F
put(t3,"Develop");
G
System.out.println(m.size());
H
class Tasks{
I
String day;
J
Tasks(String d){
Correct answer: System.out.println(m.size());
Explanation
Tasks class does not override hashCode() or equals(), so identity-based comparison is used. t1, t2, and t3 are three distinct objects, so all three put() calls add separate entries. m.size() = 3. Option 6 (System.out.println(m.size())) is the statement that outputs 3.