Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class CollectionVector
{
    public static void main(String args[])
    {
        Vector<String> vector = new Vector<String>();
        vector.add("one");
        vector.add("two");
        vector.add("three");
        vector.add("four");
        System.out.println("Original vector: " + vector);
        List<String> list = new ArrayList<String>();
        list.add("one");
        list.add("two");
        list.add("five");
        vector.addAll(list);
        System.out.print("After add all: " + vector);
    }
}


Original vector: [one, two, three, four]
After add all: [one, two, five]
Original vector: [one, two, three, four]
After add all: [one, two, three, four, five]
Original vector: [one, two, three, four]
After add all: [one, two, three, four, one, two, five]
Compilation Error
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