What will be the output of the following java code?
import java.util.HashSet;
public class Test {
public static void main(String[] args) {
HashSet hs = new HashSet();
hs.add("12");
hs.add(new String("java"));
hs.add(new StringBuffer("spring"));
hs.add(new String("hibernate"));
System.out.print(hs);
}
}
What will be the output of the following java code?
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class Test {
public static void main(String[] args) {
ArrayList al = new ArrayList();
al.add(4);
al.add(80);
al.add(56);
al.add(80);
Set st = new HashSet(al);
System.out.println(st);
}
}
What will be the output of the following java code?
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
int arr[] = { 1, 34, 56, 78, 32, 90 };
Arrays.sort(arr);
System.out.println(arr[arr.length - 3]);
}
}
What will be the output of the following java code?
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Test {
public static void main(String[] args) {
List list = new ArrayList(Arrays.asList("java", "hibernate", "spring"));
for (String str : list) {
if (str.equals("spring")) {
list.remove(str);
}
}
System.out.println(list);
}
}
What will be the output of the following java code?
import java.util.ArrayList;
import java.util.ListIterator;
public class Test {
public static void main(String[] args) {
ArrayList al = new ArrayList();
al.add("java");
al.add("spring");
al.add("456");
ListIterator itr = al.listIterator();
al.add("hibernate");
while (itr.hasNext()) {
System.out.println(itr.next());
}
}
}