Monday, October 13, 2008

Revision Quiz

1. A ____ object can store and retrieve “value” objects indexed by “key” object.
Ans: Hashtable

2.Wrapper class objects contain mutable values.
True/False?
Ans: False

3.A Vector can hold object references or primitives types.
Ans: False

4.Hashtable class implements which of the following interfaces?Ans: Map

5.String s1=new String(“MyString”);String s2=new String(“MyString”);s1==s2 will return ___.

Ans: False

6.Float.NaN or Double.NaN refers to ___
Ans: Not a number

7.The java.lang.System is a ___ class.

Ans: final

8.The ___ class is a wrapper around int data type in java.

Ans: Integer

9.java.lang.Double is a concrete subclass of abstract class java.lang.Number.
True/False
Ans:True

10.What happens when you try to compile and run the following code snippet?
public class Wrapper{
public static void main(String []a)
{
String s=”15.25”;
try {
int number=Integer.parseInt(s); //line 1
System.out.println(number); //line 2
}
catch(NumberFormatException nfe)
{
System.out.println(“sorry”);
}
catch(Exception e){ }
}
}
A) It will compile fine and display 15 when run.
B) It will compile fine and display Sorry when run.
C) It will not compile.
D) It will compile fine nothing will be displayed when run
Ans: B

11.The java.lang.Math class has ___ constructor.

A) public
B) private
C) protected
Ans: B

12.A Vector maintains object references in the order they were added.
Ans: True

13.The String class represents a mutable string

Ans: False

14.The parent class of both Integer and Character class is Number class
Ans: False

15.What happens when you try to compile and run the following code snippet?

public class WrapChar
{
public static void main(String []a)
{
Character wrapChar=new Character(“c”);//line1
System.out.println(wrapChar);//line 2
}
}
A) Compile time error at line 1
B) Compile time error at line 2
C) Compile fine and display c when run
D) Compile fine but throws RuntimeException
Ans: A

Search Amazon for Best Books on Java J2EE

Blogarama

blogarama - the blog directory

Search your favourite topics

Google