Which method in the ExecutorService interface waits for all tasks to complete after a shutdown request?

  • awaitShutdown()
  • awaitTermination()
  • isTerminated()
  • shutdownNow()
The awaitTermination() method in the ExecutorService interface is used to wait for all tasks to complete after a shutdown request has been made using the shutdown() method. It blocks until all tasks have completed or the specified timeout has passed. The isTerminated() method checks if the ExecutorService has terminated but doesn't wait.

How can a developer prevent a field from being serialized?

  • Mark the field as final.
  • Mark the field as private.
  • Mark the field as static.
  • Mark the field as transient.
In Java, to prevent a field from being serialized, you can mark it as transient. When a field is marked as transient, it will not be included in the serialization process. The other options do not directly prevent serialization. Marking a field as final has no impact on serialization. Marking it as static means the field will be serialized. Marking it as private affects only access, not serialization.

By using the keyword ________, a subclass can call a method defined in its superclass.

  • extends
  • inherit
  • override
  • super
In Java, the keyword used to call a method defined in the superclass from a subclass is super. It's commonly used to access overridden methods or constructors in the parent class.

The process of hiding the internal details of a class and showing only the things that are necessary is known as ________.

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
In Java, encapsulation is the process of hiding the internal details of a class and exposing only the essential parts. It helps in maintaining the integrity of the class and prevents unauthorized access to its data. This concept is fundamental to object-oriented programming.

Which of the following event types is not a mouse event in JavaFX?

  • KeyEvent
  • MouseDragEvent
  • MouseEvent
  • TouchEvent
In JavaFX, KeyEvent is not a mouse event; it represents keyboard events. Mouse events, such as MouseEvent and MouseDragEvent, are related to mouse input. TouchEvent deals with touch input. Understanding the distinction between these event types is essential when working with JavaFX event handling.

Which exception type must be explicitly handled or declared to be thrown in a method?

  • Checked exceptions
  • Errors
  • None of the above
  • Unchecked exceptions (Runtime)
In Java, checked exceptions (which extend the Exception class but not RuntimeException) must be explicitly handled or declared to be thrown in a method. This requirement ensures that the code handles potentially problematic situations.

In which case(s) does Binary Search perform in O(1) time complexity?

  • When the array is empty
  • When the target element is at the first index of the array
  • When the target element is at the middle of the array
  • When the target element is not present in the array
Binary Search performs in O(1) time complexity when the target element is at the first index of the sorted array. In this case, it can directly access the element and return it. When the array is empty, it still performs in O(1) time complexity as there are no elements to search. In other cases, it performs in O(log n) time complexity, where 'n' is the number of elements in the array.

Which of the following classes provides a resizable array, which can grow as needed?

  • Array
  • ArrayList
  • LinkedList
  • Vector
The ArrayList class in Java provides a resizable array that can grow dynamically as elements are added. It is part of the java.util package and is widely used for dynamic collections. LinkedList, while useful for certain scenarios, is not specifically designed as a resizable array like ArrayList. Array represents a fixed-size array, and Vector is similar to ArrayList but is synchronized, making it less efficient in most cases.

Which class is used to create a server-side socket that waits for client requests?

  • Server
  • ServerSocket
  • SocketListener
  • SocketServer
In Java, the ServerSocket class is used to create a server-side socket that listens for incoming client requests. It's an essential part of building network servers. The other options do not represent the correct class for this purpose.

Which searching algorithm would work even if the data is not sorted?

  • Binary Search
  • Linear Search
  • Merge Sort
  • Quick Sort
Linear Search is an algorithm that can work effectively on unsorted data. It sequentially checks each element in the list until a match is found or the list is exhausted. Other algorithms like Binary Search require the data to be sorted.