Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Package {
    public static void main(String[] args) {
        String[] alpha = {"I", "A", "U", "O", "E", "X", "X"};
        List list = new ArrayList();
        for (String element : alpha)
            list.add(element);
        System.out.println(Collections.frequency(list, alpha[5]));
        Collections.rotate(list, 4);
        System.out.println(list);
        Collections.swap(list, 4, 2);
        System.out.println(list);
        System.out.println(Collections.nCopies(3, "X"));
        Collections.sort(list);
        System.out.println(list);
        System.out.println(Collections.unmodifiableList(list));
        Collections.fill(list, null);
        System.out.println(list);
    }
}


2
[O, E, X, X, I, A, U]
[O, E, I, X, X, A, U]
[X, X, X]
[A, E, I, O, U, X, X]
[A, E, I, O, U, X, X]
[null, null, null, null, null, null, null]
2
[U, O, E, X, X, I, A]
[U, O, E, I, X, X, A]
[U, O, E, I, X, X, A, X, X, X]
[A, E, I, O, U, X, X, X, X, X]
[A, E, I, O, U, X, X, X, X, X]
[A, E, I, O, U, X, X, X, X, X]
Output can not be determined
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java nCopies Collections - Collections.nCopies() Method

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App