Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class VectorImplementation {
    public static void main(String[] args) {
        Vector vect = new Vector();
        vect.add("One");
        vect.add("Two");
        vect.add("Three");
        vect.add("Five");
        vect.insertElementAt("Numbers In Words", 0);
        vect.insertElementAt("Four", 4);
        System.out.println("Size : " + vect.size());
        for (int i = 0; i < vect.size(); i++) {
            System.out.print(vect.elementAt(i) + " ");
        }
        vect.removeElement("Five");
        System.out.println("\nSize : " + vect.size());
        System.out.print(vect);
    }
}


Size : 4
One Two Three Four
Size : 4
[One, Two, Three, Four]
Size : 5
One Two Three Four Five
Size : 4
[One, Two, Three, Four]
Size : 5
Numbers In Words One Two Three Four
Size : 5
[Numbers In Words, One, Two, Three, Four]
Size : 6
Numbers In Words One Two Three Four Five
Size : 5
[Numbers In Words, One, Two, Three, Four]
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