Which data structure is best suited for implementing a Last-In-First-Out (LIFO) order of elements in Java?
Queue
Stack
Set
Map
How can you access the value of an annotation's element at runtime?
By using the getAnnotation() method
getAnnotation()
By casting the annotated element to the annotation type
By using the getDeclaredAnnotation() method
getDeclaredAnnotation()
By accessing the annotation element directly as a field of the annotated element
What is the time complexity of retrieving an element from a HashSet in Java, assuming the hash function distributes elements evenly?
O(log n)
O(n log n)
O(1)
O(n)
Which of these is NOT a valid retention policy for a custom annotation in Java?
RUNTIME
CLASS
DEPLOYMENT
SOURCE
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
What is the core function of an 'ExecutorService' in Java's concurrency framework?
To define custom locking mechanisms
To manage and execute thread pools efficiently
To synchronize access to shared resources
To schedule tasks for execution at fixed intervals
Which annotation is used to indicate that a method from a superclass is being overridden?
@Override
@OverrideMethod
@Overload
@Implement
What is a custom collector in Java Streams?
A user-defined collector to perform specific aggregation operations
A mechanism for sorting stream elements in a custom order
A predefined collector provided by the Java API
A way to filter elements in a stream based on custom logic
Which interface in the Java Collections Framework represents a group of objects where duplicates are not allowed?
List
What is a key advantage of using inner classes in Java?
Improved code organization and encapsulation
Enhanced support for multithreading
Increased code execution speed
Reduced memory footprint of the program