Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class AddCollection2
{
    public static void main(String args[])
    {
        List<String> list = new ArrayList<String>();
        Collections.addAll(list, "C", "C++", "C#", "JAVA");
        System.out.println(list);
        
        String[] strs = {".Net", "UNIX"};
        Collections.addAll(list, strs);
        System.out.println(list);
        
        Collections.addAll(list, list);
        System.out.println(list);
    }
}


[C, C++, C#, JAVA]
[C, C++, C#, JAVA, .Net, UNIX]
[C, C++, C#, JAVA, .Net, UNIX]
[C, C++, C#, JAVA]
[C, C++, C#, JAVA, .Net, UNIX]
[C, C++, C#, JAVA, .Net, UNIX, C, C++, C#, JAVA]
[C, C++, C#, JAVA]
[C, C++, C#, JAVA, .Net, UNIX]
[C, C++, C#, JAVA, .Net, UNIX, C, C++, C#, JAVA, .Net, UNIX]
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App