Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this question, we use the list iterator of Java. This iterator has a method add. Hence, the iterator can add elements to a list.

For this question, we use the list iterator of Java. This iterator has a method add. Hence, the iterator can add elements to a list.

http://download.oracle.com/javase/8/docs/api/java/util/ListIterator.htm

import java.util.ListIterator; import java.util.LinkedList; public class Test { public static void main( String[] args ) { LinkedList a, b; a = new LinkedList(); b = new LinkedList(); a.add("alpha"); a.add("bravo"); a.add("tango"); a.add("charlie"); ListIterator i, j; i = a.listIterator(); j = b.listIterator(); while (i.hasNext()) { j.add(i.next()); } System.out.println(a); System.out.println(b); } }

What is the result of the execution of the above Java program?

1.charlie, tango, bravo, alpha charlie, tango, bravo, alpha

2.alpha, bravo, tango, charlie alpha, bravo, tango, charlie

3.charlie, tango, bravo, alpha alpha, bravo, tango, charlie

4.alpha, bravo, tango, charlie charlie, tango, bravo, alpha

5.Runs into an infinite loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions