You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability?
A -
Java.util.Map
B -
Java.util.List
C -
Java.util.Collection
D -
None of the above
2-
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?
A -
java.util.SortedMap
B -
java.util.TreeMap
C -
java.util.TreeSet
D -
java.util.Hashtable
3-
What is the numerical range of char?
A -
0 to 32767
B -
0 to 65535
C -
-256 to 255
D -
-32768 to 32767
4-
Which of the following are true statements?
The Iterator interface declares only three methods: hasNext, next and remove.
The ListIterator interface extends both the List and Iterator interfaces.
The ListIterator interface provides forward and backward iteration capabilities.
The ListIterator interface provides the ability to modify the List during iteration.
The ListIterator interface provides the ability to determine its position in the List.
A -
2, 3, 4 and 5
B -
1, 3, 4 and 5
C -
3, 4 and 5
D -
1, 2 and 3
5-
Which method must be defined by a class implementing the java.lang.Runnable interface?
A -
void run()
B -
public void run()
C -
public void start()
D -
void run(int priority)
6-
Which two statements are true?
Deadlock will not occur if wait()/notify() is used
A thread will resume execution as soon as its sleep duration expires.
Synchronization can prevent two objects from being accessed by the same thread.
The wait() method is overloaded to accept a duration.
The notify() method is overloaded to accept a duration.
Both wait() and notify() must be called from a synchronized context.
A -
1 and 2
B -
3 and 5
C -
4 and 6
D -
1 and 3
7-
Which of the following statements is true?
A -
If assertions are compiled into a source file, and if no flags are included at runtime, assertions will execute by default.
B -
As of Java version 1.4, assertion statements are compiled by default.
C -
With the proper use of runtime arguments, it is possible to instruct the VM to disable assertions for a certain class, and to enable assertions for a certain package, at the same time.
D -
When evaluating command-line arguments, the VM gives -ea flags precedence over -da flags.
8-
What will be the output of the program?
try
{
Float f1 = new Float("3.0");
int x = f1.intValue();
byte b = f1.byteValue();
double d = f1.doubleValue();
System.out.println(x + b + d);
}
catch (NumberFormatException e)
{
System.out.println("bad number");
}
A -
9.0
B -
bad number
C -
Compilation fails on line 13.
D -
Compilation fails on line 14.
9-
What will be the output of the program?
public class ExamQuestion6
{
static int x;
boolean catch()
{
x++;
return true;
}
public static void main(String[] args)
{
x=0;
if ((catch() | catch()) || catch())
x++;
System.out.println(x);
}
}