What is the result?

Given the code fragment:

What is the result?

Given the code fragment:

What is the result?

A.
A NullPointerException is thrown at runtime.

B.
[1, 2, 4]

C.
[1, 2, 4, null ]

D.
[1, 3, 4, null ]

E.
[1, 3, 4 ]

F.
Compilation fails.

Explanation:



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Mick B

Mick B

class ArrayList remove method takes an int as an index. Knowing like arrays index begins from 0. The element at index 2 is removed which in this case is 3.
passing null into the remove method removes first element with a null value.

ramanes

ramanes

Answer is b. why most answer in this site are wrong. do anybody know where can I get free question & answer for 808