Objects and Collections Questions and Answers

Practice Mode
Showing 10 of 38 questions
Q31
Which class implements the List interface?
  • A HashMap
  • B ArrayList
  • C HashSet
  • D TreeSet
Answer: Option B
Explanation: ArrayList is a widely used implementation of List.
Q32
Which keyword is used to refer to the current object?
  • A self
  • B me
  • C this
  • D object
Answer: Option C
Explanation: this is used to reference the current class instance.
Q33
Which of the following is not a feature of OOP?
  • A Encapsulation
  • B Abstraction
  • C Compilation
  • D Polymorphism
Answer: Option C
Explanation: Compilation is not an OOP principle.
Q34
Which method returns the size of a collection?
  • A count()
  • B total()
  • C size()
  • D number()
Answer: Option C
Explanation: size() returns the number of elements in collections.
Q35
Which collection allows null keys?
  • A Hashtable
  • B HashMap
  • C TreeMap
  • D TreeSet
Answer: Option B
Explanation: Only HashMap allows one null key.
Q36
What is the default value of object reference variables?
  • A 0
  • B empty
  • C null
  • D undefined
Answer: Option C
Explanation: Objects default to null until initialized.
Q37
Which class is best for constant-time search operations?
  • A LinkedList
  • B HashMap
  • C TreeMap
  • D ArrayList
Answer: Option B
Explanation: HashMap provides average O(1) search time.
Q38
What is the parent interface of all collections?
  • A Iterable
  • B Collection
  • C List
  • D Object
Answer: Option B
Explanation: Collection is the root interface for most collections except Map.
Questions and Answers for Competitive Exams Various Entrance Test