Objects and Collections Questions and Answers

Practice Mode
Showing 10 of 38 questions
Q21
Which wrapper class represents integer values?
  • A Float
  • B Integer
  • C Double
  • D String
Answer: Option B
Explanation: Integer is the wrapper class for int.
Q22
Which collection class maintains insertion order?
  • A HashSet
  • B TreeSet
  • C LinkedHashSet
  • D PriorityQueue
Answer: Option C
Explanation: LinkedHashSet preserves insertion order.
Q23
Which method adds an element to an ArrayList?
  • A insert()
  • B put()
  • C add()
  • D push()
Answer: Option C
Explanation: add() inserts new elements into an ArrayList.
Q24
Which reference indicates an object is not pointing anywhere?
  • A void
  • B delete
  • C null
  • D none
Answer: Option C
Explanation: null means the reference variable does not refer to any object.
Q25
Which of these is not a Java collection interface?
  • A List
  • B Set
  • C Map
  • D Structure
Answer: Option D
Explanation: Structure is not part of Java Collections Framework.
Q26
Which class stores elements in sorted order?
  • A TreeSet
  • B HashSet
  • C ArrayList
  • D Vector
Answer: Option A
Explanation: TreeSet stores elements in ascending sorted order.
Q27
Which method removes all elements from a collection?
  • A clear()
  • B delete()
  • C removeAll()
  • D empty()
Answer: Option A
Explanation: clear() empties a collection.
Q28
Which concept allows objects to take many forms?
  • A Abstraction
  • B Encapsulation
  • C Polymorphism
  • D Inheritance
Answer: Option C
Explanation: Polymorphism allows the same method to behave differently.
Q29
Which operator is used to access object members?
  • A ::
  • B ->
  • C .
  • D :
Answer: Option C
Explanation: The dot operator accesses object methods and variables.
Q30
Which collection allows FIFO (First-In, First-Out) order?
  • A List
  • B Queue
  • C Set
  • D Map
Answer: Option B
Explanation: A Queue follows FIFO ordering.
Questions and Answers for Competitive Exams Various Entrance Test