A

Admin • 828.43K Points
Coach

Q. What will be the output of the following code

Code:
import java.util.Iterator;
import java.util.Vector;

public class VectorTest {
public static void main(String args[])
{
Vector<String> vector= new Vector<String>();
vector.add(“1”);
vector.add(“2”);

Iterator<String> iterator=vector.iterator();
while(iterator.hasNext())
{

System.out.println(iterator.next());
}
}
}
  • (A) 1 2
  • (B) 1 2 3
  • (C) 3 2 1
  • (D) ConcurrentModificationException
  • Correct Answer - Option(A)
  • Views: 12
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.