Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class GetSubList
{
    public static void main(String args[])
    {
        Vector<String> vector = new Vector<String>();
        vector.add("C");
        vector.add("C++");
        vector.add("C#");
        vector.add("JAVA");
        vector.add("RUBY");
        System.out.println("Original vector: " + vector);

        List<String> list = vector.subList(2, 4);
        System.out.print("Sub list from vector: " + list);
    }
}


Original vector: [C, C++, C#, JAVA, RUBY]
Sub list from vector: [C#, JAVA]
Original vector: [C, C++, C#, JAVA, RUBY]
Sub list from vector: [C#, JAVA, RUBY]
Original vector: [C, C++, C#, JAVA, RUBY]
Sub list from vector: [JAVA]
Original vector: [C, C++, C#, JAVA, RUBY]
Sub list from vector: [C#, RUBY]
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