Which of these Java keywords is NOT an access modifier?
protected
private
public
static
✓
Correct Answer
static
static is a non-access modifier used for members that belong to the class itself rather than to any specific instance. public, private, and protected are Java access modifiers that control the visibility of classes, fields, and methods.
Question 2
Which of these Java Collection interfaces or classes is NOT primarily part of the java.util. List hierarchy?
LinkedList
HashSet
✓
Vector
ArrayList
Correct Answer
HashSet
HashSet implements the java.util. Set interface, which is a different hierarchy for collections that do not allow duplicate elements. ArrayList, LinkedList, and Vector are classes that implement the java.util. List interface.
Question 3
Which of these exception types in Java is NOT a checked exception?
NullPointerException
✓
ClassNotFoundException
IOException
SQLException
Correct Answer
NullPointerException
IOException, SQLException, and ClassNotFoundException are checked exceptions, meaning the compiler requires them to be caught or declared. NullPointerException is an unchecked exception, a subclass of RuntimeException, and does not require explicit handling.
Question 4
Which of these is NOT a valid type argument for a generic type in Java?
Integer
List
int
✓
String
Correct Answer
int
String, Integer, and List are all reference types, which are valid as type arguments for generic types in Java. int is a primitive type and cannot be used directly as a generic type argument; its wrapper class, Integer, must be used instead.
Question 5
Which of these methods is NOT part of the java.lang. Object class and used for inter-thread communication?
notifyAll()
notify()
wait()
sleep()
✓
Correct Answer
sleep()
sleep() is a static method of the java.lang. Thread class that causes the currently executing thread to cease execution for a specified period. wait(), notify(), and notifyAll() are methods of the java.lang. Object class used for inter-thread communication based on an object's monitor.
Question 6
Which of these is NOT considered one of the core principles of Object-Oriented Programming?
Polymorphism
Inheritance
Debugging
✓
Encapsulation
Correct Answer
Debugging
Encapsulation, Inheritance, and Polymorphism are three of the core principles of Object-Oriented Programming. Debugging is a software development activity to find and fix errors, not an OOP principle itself.
Question 7
Three of these collection types reject duplicate elements. Which one does not?
LinkedHashSet
TreeSet
HashSet
ArrayList
✓
Correct Answer
ArrayList
HashSet, TreeSet, and LinkedHashSet are implementations of the java.util. Set interface, which by definition does not allow duplicate elements. ArrayList is an implementation of the java.util. List interface, which allows duplicate elements and maintains insertion order.
Question 8
Which of these is NOT a valid construct for handling exceptions in Java?
try-finally
try-catch
catch-finally
✓
try-catch-finally
Correct Answer
catch-finally
try-catch, try-finally, and try-catch-finally are all valid constructs for handling exceptions in Java. A catch-finally block without an preceding try block is syntactically invalid.
Question 9
Which of these is NOT a valid wildcard type argument syntax in Java generics?
<? super Integer>
<String>
✓
<? extends Number>
<?>
Correct Answer
<String>
<String> is a concrete type argument, specifying a specific type, not a wildcard. <? extends Number>, <? super Integer>, and <?> (unbounded wildcard) are all valid wildcard type argument syntaxes in Java generics.
Question 10
Which of these is NOT a direct mechanism for defining a task to be executed by a thread in Java?
Instantiating a Callable
Implementing Runnable
Using ExecutorService
✓
Extending Thread
Correct Answer
Using ExecutorService
Implementing Runnable, Extending Thread (and overriding its run method), and Instantiating a Callable (which defines a task with a return value) are direct mechanisms for defining a task for concurrent execution. ExecutorService is a framework that manages thread pools and executes tasks, rather than being a mechanism for defining the task itself.
Question 11
Which of these Java constructs is NOT primarily used for achieving abstraction?
final class
✓
abstract class
public methods
interface
Correct Answer
final class
interface, abstract class, and public methods (as part of encapsulation to hide implementation) are primarily used for achieving abstraction in Java. A final class prevents inheritance and method overriding, which is related to limiting extensibility rather than primarily defining abstract behavior or hiding implementation details through an abstract contract.
Question 12
Which of these collection classes does NOT guarantee to maintain elements in insertion order?
Vector
TreeSet
✓
LinkedHashMap
ArrayList
Correct Answer
TreeSet
LinkedHashMap, ArrayList, and Vector all maintain the order in which elements were inserted. TreeSet orders its elements according to their natural order or by a Comparator provided at set creation time, not by insertion order.
Question 13
Which of these is NOT a subclass of java.lang. Error?
IllegalArgumentException
✓
OutOfMemoryError
StackOverflowError
NoClassDefFoundError
Correct Answer
IllegalArgumentException
StackOverflowError, OutOfMemoryError, and NoClassDefFoundError are all direct or indirect subclasses of java.lang. Error, representing serious problems that applications should not try to catch. IllegalArgumentException is a subclass of java.lang. RuntimeException, indicating an invalid argument was passed to a method.
Question 14
Which of these is NOT a direct consequence or feature of Java's generics implementation using type erasure?
Reduced need for explicit type casting
Generic type information available at runtime for type parameters
✓
Backward compatibility with older Java versions
Compile-time type safety
Correct Answer
Generic type information available at runtime for type parameters
Compile-time type safety, reduced need for explicit type casting, and backward compatibility with older Java versions are all direct consequences or features of Java's generics implementation using type erasure. Generic type information for type parameters is NOT available at runtime (it is erased), which is a key characteristic of type erasure.
Question 15
Which of these Java keywords is NOT directly related to managing thread synchronization or memory visibility for concurrent access?
transient
✓
synchronized
volatile
wait
Correct Answer
transient
synchronized, volatile, and wait (a method of Object used with synchronized blocks) are all directly related to managing thread synchronization or ensuring memory visibility across threads. transient is a keyword used in serialization to mark fields that should not be serialized; it has no direct role in concurrency management.