NewsTicker

JAVA QUIZ


Online Examination for JAVA Language Quiz Question And Answer





Online Test


1. Which is a reserved word in the Java programming language?

method
native
subclasses
reference
 -----------------------------------------------------------------------------------------------------------------
2. Which is a valid keyword in java?

interface
string
Float
unsigned
-----------------------------------------------------------------------------------------------------------------
3. Which is true about an anonymous inner class?

It can extend exactly one class and implement exactly one interface
It can extend exactly one class and can implement multiple interfaces
It can extend exactly one class or implement exactly one interface
It can implement multiple interfaces regardless of whether it also extends a class
-----------------------------------------------------------------------------------------------------------------
4. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

public
private
protected
transient
-----------------------------------------------------------------------------------------------------------------
5. What is the name of the method used to start a thread execution?

init();
start();
run();
resume();
-----------------------------------------------------------------------------------------------------------------
6. What is the value of "d" after this line of code has been executed?double d = Math.round ( 2.5 + Math.random() );

2
3
4
2.5
-----------------------------------------------------------------------------------------------------------------
7. Which of the following would compile without error?

int a = Math.abs(-5);
int b = Math.abs(5.0);
int c = Math.abs(5.5F);
int d = Math.abs(5L);
-----------------------------------------------------------------------------------------------------------------
8. Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?

TreeMap
HashMap
LinkedHashMap
The answer depends on the implementation of the existing instance
-----------------------------------------------------------------------------------------------------------------
9. Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

java.lang.String
java.lang.Double
java.lang.StringBuffer
java.lang.Character
-----------------------------------------------------------------------------------------------------------------
10. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

java.util.HashSet
java.util.LinkedHashSet
java.util.List
java.util.ArrayList
-----------------------------------------------------------------------------------------------------------------
11. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

java.util.Map
java.util.Set
java.util.List
java.util.Collection
-----------------------------------------------------------------------------------------------------------------
12. Which interface does java.util.Hashtable implement?

Java.util.Map
Java.util.List
Java.util.HashTable
Java.util.Collection
-----------------------------------------------------------------------------------------------------------------
Score =
Correct answers: