What will LocalDate.now().plusDays(1) return?
LocalDate.now().plusDays(1)
The date one day after the current date.
The date one day before the current date.
An error, as the plusDays() method does not exist.
plusDays()
The current date and time.
What is the purpose of defining a custom annotation in Java?
To create new keywords in the Java language
To control access modifiers for classes and methods
To define new data types
To attach metadata to classes, methods, or fields
Which annotation is used to suppress compiler warnings in Java?
@DisableWarnings
@IgnoreWarnings
@NoWarnings
@SuppressWarnings
Which method is used to convert a Stream back to a List?
collect(Collectors.toList())
filter(Collectors.toList())
reduce(Collectors.toList())
map(Collectors.toList())
What does the File.createNewFile() method do if a file with the same name already exists in the specified location?
File.createNewFile()
It overwrites the existing file with an empty file.
It appends a number to the file name to create a unique file.
It throws a FileNotFoundException.
FileNotFoundException
It returns false without creating a new file.
false
Which interface must a custom annotation extend directly or indirectly?
java.lang.Class
java.lang.reflect.AnnotatedElement
java.lang.annotation.ElementType
java.lang.annotation.Annotation
What is the core function of an 'ExecutorService' in Java's concurrency framework?
To define custom locking mechanisms
To synchronize access to shared resources
To schedule tasks for execution at fixed intervals
To manage and execute thread pools efficiently
Can a method be both generic and static in Java?
No, generic methods cannot be static.
Yes, but the type parameter should be declared before the method name.
Yes, but the type parameter should be declared after the 'static' keyword.
Yes, there are no restrictions.
Which of these is NOT a valid retention policy for a custom annotation in Java?
RUNTIME
CLASS
SOURCE
DEPLOYMENT
Which Java method would you use to find the index of the first occurrence of a specific substring within a string?
substring()
indexOf()
length()
charAt()