Can a method be both generic and static in Java?
Yes, there are no restrictions.
Yes, but the type parameter should be declared before the method name.
No, generic methods cannot be static.
Yes, but the type parameter should be declared after the 'static' keyword.
What does the File.createNewFile() method do if a file with the same name already exists in the specified location?
File.createNewFile()
It throws a FileNotFoundException.
FileNotFoundException
It appends a number to the file name to create a unique file.
It returns false without creating a new file.
false
It overwrites the existing file with an empty file.
What is the primary purpose of using the @Deprecated annotation in Java?
To indicate that a method is no longer recommended for use
To throw a runtime exception if the method is called
To prevent a method from being inherited
To hide methods from documentation
Which class in the java.time package represents a date without a time component?
java.time
LocalDateTime
LocalDate
ZonedDateTime
Instant
Which of the following is a key advantage of using the Java NIO (New I/O) package for file handling?
It automatically handles file compression and decompression.
It offers support for non-blocking I/O operations, enhancing application responsiveness.
It eliminates the need for exception handling during file I/O.
It provides a simpler API for basic file operations like reading and writing.
Which data structure is best suited for implementing a Last-In-First-Out (LIFO) order of elements in Java?
Map
Set
Stack
Queue
Which interface does Java primarily use to represent a task that can be executed concurrently?
Runnable
Callable
Iterable
Threadable
The 'flatMap' operation on a stream is used for:
Reducing the stream to a single summary value
Flattening a stream of collections into a single stream
Filtering elements based on a predicate
Transforming each element into a single new element
Which of the following is NOT a valid way to create a Stream in Java?
new Stream()
Stream.of(1, 2, 3)
list.stream()
Arrays.stream(array)
What does the 'E' typically represent in a generic type parameter like 'List<E>'?
Element
Exception
Entry
Enum