Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class Competition<T> {
    String glom(Collection<?> obj) {
        String result = "";
        for (Object o : obj)
            result += o;
        return result;
    }
    int glom(List<Integer> ints) {
        int result = 0;
        for (int i : ints)
            result += i;
        return result;
    }
    public static void main(String args[]) {
        List<String> strings = Arrays.asList("1", "2", "3");
        System.out.println(new Competition().glom(strings));
    }
}


6
123
Some other output
Output can not be determined
Compilation Error or 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