Which interface in the Java Collections Framework represents an ordered collection of elements, allowing duplicates?
Map
Set
Queue
List
What is the primary purpose of using the @Deprecated annotation in Java?
To prevent a method from being inherited
To indicate that a method is no longer recommended for use
To hide methods from documentation
To throw a runtime exception if the method is called
What distinct advantage does a 'Callable' interface offer over 'Runnable' in Java?
Callable can be used with traditional threads, while Runnable requires an ExecutorService
Callable can throw checked exceptions, while Runnable cannot
Callable is used for tasks that don't return a value, while Runnable is for tasks that do
Callable executes faster than Runnable
Which method is used to add elements to the end of a Queue in Java?
offer()
add()
push()
insert()
Which annotation is used to indicate that a method from a superclass is being overridden?
@OverrideMethod
@Overload
@Implement
@Override
Which of the following is true about the 'peek' operation?
It's an intermediate operation primarily used for debugging
It's an intermediate operation that modifies the stream elements
It's a terminal operation that returns a new Stream
It's a terminal operation that triggers stream processing
What is the core function of an 'ExecutorService' in Java's concurrency framework?
To synchronize access to shared resources
To schedule tasks for execution at fixed intervals
To manage and execute thread pools efficiently
To define custom locking mechanisms
Which interface must a custom annotation extend directly or indirectly?
java.lang.annotation.Annotation
java.lang.annotation.ElementType
java.lang.reflect.AnnotatedElement
java.lang.Class
What does the File.createNewFile() method do if a file with the same name already exists in the specified location?
File.createNewFile()
It returns false without creating a new file.
false
It throws a FileNotFoundException.
FileNotFoundException
It appends a number to the file name to create a unique file.
It overwrites the existing file with an empty file.
What happens when a generic class is instantiated with a primitive type in Java?
It works as expected.
A compile-time error occurs.
The primitive type is autoboxed to its wrapper class.
A runtime exception is thrown.