These HashMap multiple-choice questions and their answers will help you strengthen your grip on the subject of HashMap. You can prepare for an upcoming exam or job interview with these HashMap MCQs.
So scroll down and start answering.
A. Equals
B. Finalize
C. ToString
D. Clone
E. All of the above.
A. Constructor
B. Catch
C. Finalize
D. None of these
A. True
B. False
A. A Canvas object
B. A Graphics object
C. An Image object
D. A paint object
A. Sequential
B. Selection -- if and switch statements
C. Iteration -- for loop, while loop and do-while loop
A. Long
B. String
C. Int
D. Char
A. A JSP page.
B. A JavaBean.
C. A servlet.
D. A session manager.
A. Double D = 45456.444;
B. Long L = 45784;
C. Int I = L;
D. Int J = (int) D;
What will be the output of the program?
import java.util.*;
class H
{
public static void main (String[] args)
{
Object x = new Vector().elements();
System.out.print((x instanceof Enumeration)+",");
System.out.print((x instanceof Iterator)+",");
System.out.print(x instanceof ListIterator);
}
}
A.
Prints: false,false,false
B.
Prints: false,false,true
C.
Prints: false,true,false
D.
Prints: true,false,false
A. Int [] myList = {
B. Int [] myList = (5, 8, 2);
C. Int myList [] [] = {4,9,7,0};
D. Int myList [] = {4, 3, 7};
A. Boolean b1 = 0;
B. Boolean b2 = 'false';
C. Boolean b3 = false;
D. Boolean b4 = Boolean.false();
E. Boolean b5 = no;
A. Calling the SetPriority() method on a Thread object.
B. Calling the wait() method on an object.
C. Calling notify() method on an object.
D. Calling read() method on an InputStream object.
A. A try statement must have at least one corresponding catch block.
B. Multiple catch statements can catch the same class of exception more than once.
C. An Error that might be thrown in a method must be declared as thrown by that method, or be handled within that method.
D. Except in case of VM shutdown, if a try block starts to execute, a corresponding finally block will always start to execute.
class A
{
A( )
{ }
}
class B extends A
{ }
Which statement is true?
A.
Class B'S constructor is public.
B.
Class B'S constructor has no arguments.
C.
Class B'S constructor includes a call to this( ).
D.
None of these.
What will be the output of the program?
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
A.
Finally
B.
Compilation fails.
C.
The code runs with no output.
D.
An exception is thrown at runtime.