Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class CollectionProgram2
{
    public static void main(String args[])
    {
        Vector<String> vector = new Vector<String>();
        Enumeration<String> strs = null;
        vector.add("Merit ");
        vector.add("Campus ");
        vector.add("to ");
        vector.add("you ");
        vector.add("welcomes ");
        vector.add("become ");
        vector.add("a ");
        vector.add("good ");
        vector.add("");
        vector.add("programmer.");
        strs = vector.elements();
        Collections.swap(vector, 2, 4);

        while(strs.hasMoreElements() && !vector.isEmpty())
        {
            System.out.print(strs.nextElement());
        }
    }
}


Merit Campus welcomes you to become a good  programmer.
Merit you welcomes Campus to become a good  programmer.
Merit Campus welcomes you to become a good programmer.
Merit Campus welcomes you to become a good
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Vector

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App