Menu
Topics Index
...
`

Malayalam


If you need explanation Read this topic

If you need Answer Take test on this topic

Malayalam
What will be the output of the following program?
import java.util.*;
public class Malayalam {
    public static void main(String[] args) {
        Set<String> malayalam = Collections.singleton("malayalam");
        System.out.println(malayalam);
        System.out.println(malayalam.iterator().next());
    }
}

A. [malayalam]
malayalam
B. malayalam
malayalam
C. Compilation Error
D. Runtime Error
Topic: Java Singleton

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans:A  first singleton method return set obj with one element "malayalam" sop prints [malayalam] and second sop prints "malayalam"

Posted by Indra Chereddy    2014-06-10 04:47:33


Ans is A as malayalam is passed to singleton method and prints set with its element and 2nd print statement prints malayalam

Posted by Bharath Yelchuri    2014-06-10 07:52:21


Congratulations Bharath Yelchuri. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-11 04:01:43


© meritcampus 2019

All Rights Reserved.

Open In App