Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class IamwhatIam {
    public static void main(String[] args) {
        List<String> truth = new ArrayList<String>();
        truth.add("I");
        truth.add(" am ");
        truth.add("what");
        truth.add(" I ");
        String[] truths = truth.toArray(new String[truth.size()]);
        System.out.println(truth);
        List<String> trooth = Arrays.asList(truths);
        System.out.println(trooth);
        trooth.add(truths[1]);
        System.out.println(trooth);
    }
}


[I,  am , what,  I ]
[I,  am , what,  I ]
[I,  am , what,  I , I]
[I,  am , what,  I ]
[I,  am , what,  I ]
[I,  am , what,  I ,  am ]
I am what I
I am what I
I am what I  am
I am what I
I am what I
I am what I I
Compilation Error
Runtime Error

Doubts

Problems

Topic: java.util.Arrays - Class Arrays In Collection Framework

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App