What will be the output of the following java code?
import java.util.Collections;
public class Test {
public static void main(String[] args) {
Object[] obj = { new Double(34.56), new String("java"), new Boolean(false), new Integer(87) };
Collections.reverseOrder();
for (int i = 0; i < obj.length; i++) {
System.out.print(obj[i].toString());
}
}
}
What will be the output of the following java code?
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class Test {
public static Iterator hello(List list) {
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("2");
list.add("4");
list.add("6");
Iterator itr = hello(list);
for (Object obj : itr) {
System.out.print(obj + ",");
}
}
}
What will be the output of the following java code?
import java.util.Collection;
import java.util.LinkedList;
public class Test {
public static Collection hello() {
Collection list = new LinkedList();
list.add("A");
list.add("M");
list.add("H");
return list;
}
public static void main(String[] args) {
for (Object obj : hello()) {
System.out.print(obj + ",");
}
}
}
What will be the output of the following java code?
import java.util.LinkedHashSet;
import java.util.Set;
public class Test {
public static void main(String[] args) {
Set set = new LinkedHashSet();
set.add(2);
set.add(4);
System.out.println(set);
}
}
What will be the output of the following java code?
import java.util.PriorityQueue;
public class Test {
public static void main(String[] args) {
PriorityQueue pq = new PriorityQueue();
pq.add("Java");
pq.add("Spring");
pq.add("Hibernate");
System.out.println(pq.element() + "," + pq.peek());
}
}