Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class ListContains
{
    public static void main(String[] args)
    {
        List list = Collections.nCopies(6, "A");
        System.out.print("List contains: ");
        Iterator itr = list.iterator();
        while (itr.hasNext())
            System.out.print(itr.next() + " ");
    }
}


List contains: A A A A A A
List contains: A A A A A A A
List contains: 6 A
Compilation Error because there is no such method as nCopies
Compilation Error or Runtime Error for some other reason

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