Can a method be both generic and static in Java?
No, generic methods cannot be static.
Yes, but the type parameter should be declared after the 'static' keyword.
Yes, but the type parameter should be declared before the method name.
Yes, there are no restrictions.
Which of these is NOT a valid retention policy for a custom annotation in Java?
SOURCE
CLASS
DEPLOYMENT
RUNTIME
What is the primary benefit of using generics in Java?
Reduced code duplication
Enhanced performance at runtime
Stronger type checking at compile time
Improved code readability
What is a custom collector in Java Streams?
A way to filter elements in a stream based on custom logic
A user-defined collector to perform specific aggregation operations
A predefined collector provided by the Java API
A mechanism for sorting stream elements in a custom order
Which interface must a class implement to be eligible for serialization in Java?
Cloneable
Parcelable
Serializable
Iterable
What will LocalDate.now().plusDays(1) return?
LocalDate.now().plusDays(1)
An error, as the plusDays() method does not exist.
plusDays()
The current date and time.
The date one day before the current date.
The date one day after the current date.
What is the primary purpose of using the @Deprecated annotation in Java?
To throw a runtime exception if the method is called
To indicate that a method is no longer recommended for use
To prevent a method from being inherited
To hide methods from documentation
Which keyword is used to create a generic method in Java?
generic
template
No specific keyword is required
typeparam
In the java.time API, which class represents a specific point in time, such as a timestamp?
java.time
Instant
LocalDateTime
LocalDate
LocalTime
What distinct advantage does a 'Callable' interface offer over 'Runnable' in Java?
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 can be used with traditional threads, while Runnable requires an ExecutorService
Callable executes faster than Runnable