A

Admin • 828.43K Points
Coach

Q. What will be the output of the following code –

Code:
import java.util.List;
import java.util.ListIterator;
import java.util.ArrayList;

public class ArrayListTest
{
public static void main (String args[])
{
List<String> arrayList = new ArrayList<String>();
arrayList.add(“a”);
arrayList.add(“b”);

ListIterator<String> listIterator = arrayList.listIterator();
while (listIterator.hasNext())
{
System.out.println(listIterator.next());
listIterator.previous( );
}
}

}
  • (A) a b a
  • (B) a b
  • (C) Will print ‘a’ infinite times
  • (D) a
  • Correct Answer - Option(C)
  • Views: 18
  • 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.