Which method converts a stream of strings to a single comma-separated string?
reduce(", ", String::concat)
map(String::concat).collect(Collectors.toList())
Both A and B
collect(Collectors.joining(", "))
How can you access the value of an annotation's element at runtime?
By using the getDeclaredAnnotation() method
getDeclaredAnnotation()
By casting the annotated element to the annotation type
By using the getAnnotation() method
getAnnotation()
By accessing the annotation element directly as a field of the annotated element
Which annotation is used to suppress compiler warnings in Java?
@DisableWarnings
@SuppressWarnings
@IgnoreWarnings
@NoWarnings
Which keyword is used to create a generic method in Java?
typeparam
No specific keyword is required
template
generic
Can a method be both generic and static in Java?
Yes, but the type parameter should be declared after the 'static' keyword.
Yes, there are no restrictions.
Yes, but the type parameter should be declared before the method name.
No, generic methods cannot be static.
Which interface does Java primarily use to represent a task that can be executed concurrently?
Callable
Threadable
Runnable
Iterable
What will be the output of the following Java code snippet?
String str = "Hello World"; System.out.println(str.substring(6));
Hello World
World
Hello
In Java NIO, what is the purpose of a Selector?
Selector
It represents an open connection to a file for reading or writing data.
It manages multiple channels and allows for efficient handling of I/O events.
It serializes and deserializes objects to and from NIO channels.
It provides a buffer for storing data read from or written to a channel.
Which built-in Java annotation is used to indicate that a method overrides a method in its superclass?
@Deprecated
@Override
@FunctionalInterface
What is the purpose of the StringBuilder class in Java?
StringBuilder
To perform regular expression matching.
To store large text files.
To create immutable strings.
To efficiently build mutable strings.