Loading

Q1.

Which of the following is TRUE about a List in Java?

A. It does not allow duplicate elements

B. It maintains insertion order

C. It does not allow null values

D. It is unordered

Q2.

 Which of the following classes implements the List interface?

A. HashMap

B. TreeSet

C. ArrayList

D. PriorityQueue

Q3.

Which method is used to get the number of elements in a List?

A. length()

B. count()

C. size()

D. getSize()

Q4.

 What happens if you try to access an index that does not exist in a List?

A. Returns null

B. Compilation error

C. Throws IndexOutOfBoundsException

D. Ignores the call

Q5.

 Which of the following is NOT a characteristic of a List in Java?

A. Allows duplicates

B. Maintains insertion order

C. Provides index-based access

D. Automatically sorts elements