What is the output(Generic Map)? : Questions « Utility Classes « SCJP






import java.util.HashMap;
import java.util.Map;

public class MainClass {
  public static void main(String[] args) {
    Map<ToDos, String> m = new HashMap<ToDos, String>();
    ToDos t1 = new ToDos("Monday");
    ToDos t2 = new ToDos("Monday");
    ToDos t3 = new ToDos("Tuesday");
    m.put(t1, "doLaundry");
    m.put(t2, "payBills");
    m.put(t3, "cleanAttic");
    System.out.println(m.size());
  }
}

class ToDos {
  String day;

  ToDos(String d) {
    day = d;
  }

  public boolean equals(Object o) {
    return ((ToDos) o).day == this.day;
  }
  // public int hashCode() { return 9; }
}








8.32.Questions
8.32.1.The Object class is final(True/False).
8.32.2.Answer: Object class and final
8.32.3.The Class class can be used to load other classes(True/False).
8.32.4.Answer: class loader
8.32.5.The ClassLoader class can be used to load other classes(True/False).
8.32.6.Answer: ClassLoader and class loading
8.32.7.Which of the following classes is used to perform basic console I/O?
8.32.8.Answer: console I/O
8.32.9.Which of the following is not a wrapper class?
8.32.10.Answer: wrapper class
8.32.11.What is the output from the following code(Boolean class and if statement)?
8.32.12.Answer: Boolean class and if statement
8.32.13.What is the output of the following program(string concatenation)?
8.32.14.Answer: string concatenation
8.32.15.Which of the following methods are methods of the Math class?
8.32.16.Answer: Math class
8.32.17.Error and Exception classes extend Throwable(True/False).
8.32.18.Answer: Error and Exception
8.32.19.The Integer class extends the Number class(True/False).
8.32.20.Answer: Integer class and Number class
8.32.21.What is the output from the following code(Vector class)?
8.32.22.Answer: Vector class
8.32.23.What is the output from the following code(Stack)?
8.32.24.Answer: Stack
8.32.25.Which of the following extend the Collection interface?
8.32.26.Answer: Collection interface
8.32.27.Which of the following may have duplicate elements?
8.32.28.Answer: collection allowing duplicate elements
8.32.29.Can a null value be added to a List?
8.32.30.Answer: null value and List
8.32.31.What is the output of the following program(HashSet)?
8.32.32.Answer: HashSet
8.32.33.What is the output of the following program(TreeMap)?
8.32.34.Answer: TreeMap
8.32.35.Which statements could be inserted at // INSERT DECLARATION HERE to allow this code to compile and run?
8.32.36.Answer: generic List
8.32.37.What is the output(generic TreeSet)?
8.32.38.Answer: generic TreeSet
8.32.39.What is the output(Generic Map)?
8.32.40.Answer: Generic Map