Which interface must a custom annotation extend directly or indirectly?
java.lang.annotation.Annotation
java.lang.reflect.AnnotatedElement
java.lang.Class
java.lang.annotation.ElementType
Which method converts a stream of strings to a single comma-separated string?
reduce(", ", String::concat)
collect(Collectors.joining(", "))
Both A and B
map(String::concat).collect(Collectors.toList())
Which keyword is used to create a generic method in Java?
generic
typeparam
template
No specific keyword is required
Which List implementation in Java uses a dynamic array to store elements and provides fast access to elements by their index?
List
LinkedList
Vector
Stack
ArrayList
What is the primary purpose of using the @Deprecated annotation in Java?
To prevent a method from being inherited
To throw a runtime exception if the method is called
To hide methods from documentation
To indicate that a method is no longer recommended for use
Which mechanism is best suited for coordinating communication between threads where one thread produces data and another consumes it?
Using 'volatile' variables
Directly sharing objects between threads
Employing a 'BlockingQueue'
Using a 'Semaphore'
What is the purpose of defining a custom annotation in Java?
To define new data types
To attach metadata to classes, methods, or fields
To control access modifiers for classes and methods
To create new keywords in the Java language
Which interface is used to create a type-safe heterogeneous container in Java?
Collection
Iterable
Comparable
Iterator
What is the primary purpose of an interface in Java?
To define a template for object creation
To enforce specific method implementations
To create multiple inheritance of classes
To define a contract for classes to adhere to
Which method in the String class is used to compare two strings lexicographically ignoring case?
String
equals()
compareToIgnoreCase()
equalsIgnoreCase()
compareTo()