Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Hp00001 {
    public static void main(String[] args) {
        Vector vect = new Vector();
        vect.add("1");    vect.add("2");
        vect.add("3");    vect.add("4");
        vect.add("5");    vect.add("6");
        vect.add("7");    vect.add("8");
        vect.add("9");    vect.add("10");
        vect.add("11");
        Object[] obj = new Object[11];
        vect.copyInto(obj);
        Arrays.sort(obj);
        Collections.reverse(vect);
        for (int index = 0; index < 11; index++)
            if (vect.get(index) != obj[index])
                System.out.print(vect.get(index) + " ");
    }
}


1 2 3 4 6 7 8 9 10 11
1 2 3 4 6 7 8 9 11
11 10 9 8 7 6 4 3 2 1
11 9 8 7 6 4 3 2 1
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