Collections Framework In Java - Study Mode

[#136] What will be the output of the following Java code? import java.util.*
class hashtable
{
public static void main(String args[])
{
Hashtable obj = new Hashtable()
obj.put("A", new Integer(3))
obj.put("B", new Integer(2))
obj.put("C", new Integer(8))
obj.remove(new String("A"))
System.out.print(obj)
}
}
Correct Answer

(A) {C=8, B=2}

[#137] What will be the output of the following Java program? import java.util.*
class Maps
{
public static void main(String args[])
{
HashMap obj = new HashMap()
obj.put("A", new Integer(1))
obj.put("B", new Integer(2))
obj.put("C", new Integer(3))
System.out.println(obj.keySet())
}
}
Correct Answer

(A) [A, B, C]

[#138] What will be the output of the following Java code? import java.util.*
class date
{
public static void main(String args[])
{
Date obj = new Date()
System.out.print(obj)
}
}
Correct Answer

(D) Prints Present Time & Date

[#139] What is the length of the application box made in the following Java program? import java.awt.*
import java.applet.*
public class myapplet extends Applet
{
Graphic g
g.drawString("A Simple Applet",20,20)
}
Correct Answer

(C) Compilation Error

[#140] What will be the output of the following Java code snippet? public class Test
{
public static void main(String[] args)
{
Set s = new HashSet()
s.add(new Long(10))
s.add(new Integer(10))
for(Object object : s)
{
System.out.println("test - "+object)
}
}
}
Correct Answer

(A) Test - 10 Test - 10