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.

What is the purpose of the serialVersionUID field and how does it play a role during deserialization?

  • It determines whether an object can be serialized or not
  • It helps prevent security vulnerabilities in deserialization
  • It is a randomly generated unique identifier
  • It specifies the version of the class, ensuring compatibility during deserialization
The serialVersionUID field is used to specify the version of a class during serialization. It plays a crucial role during deserialization by ensuring compatibility. If the version of the class that was serialized differs from the version during deserialization, it can lead to InvalidClassException. This field helps maintain compatibility and avoid issues. The other options are not the primary purpose of serialVersionUID.

If a program encounters an issue while writing to a file and you haven’t handled exceptions, the program will ________.

  • continue execution
  • display an error message
  • pause execution
  • terminate without any error message
If a program encounters an issue while writing to a file and exceptions are not properly handled, the program will terminate abruptly without any error message. This can lead to unexpected behavior and data loss. It's crucial to handle exceptions when working with file I/O to gracefully manage errors and provide meaningful feedback.

The ______ class is used to deserialize objects in Java.

  • Deserializer
  • InputStream
  • ObjectInputStream
  • Serialization
In Java, the ObjectInputStream class is used to deserialize objects. Deserialization is the process of converting serialized objects back into their original form, and this class provides methods for reading objects from a stream. The other options are not responsible for deserialization.

The ________ interface in Java provides a way to traverse, filter, and extract data.

  • Collection
  • Iterable
  • Iterator
  • Stream
The Iterable interface in Java provides a way to traverse (iterate over) a collection of elements. It allows you to loop through the elements and perform operations on them. While it doesn't provide built-in filtering or extraction like Streams, it serves as a foundation for working with collections.

A method or a data member which is declared as ________ is accessible to all classes in the Java program.

  • default (package-private)
  • private
  • protected
  • public
In Java, when a method or data member is declared as "public," it is accessible to all classes, regardless of their location in the program. This is the highest level of visibility, and it allows unrestricted access from any part of the program.

The switch case in Java can be used with data types like _______, _______, and _______.

  • byte, short, int
  • char, long, byte
  • double, string
  • int, float, boolean
In Java, the switch case can be used with data types like char, long, and byte. While other data types like int, float, boolean, double, and String are commonly used in Java, they are not directly compatible with the switch case. This limitation is important to consider when using switch statements.

How can you create a bi-directional binding between two properties in JavaFX?

  • By manually updating the properties.
  • Using the addBinding() method.
  • Using the bind() method.
  • Using the bindBidirectional() method.
To create a bi-directional binding between two properties in JavaFX, you can use the bindBidirectional() method provided by the javafx.beans.property package. This method establishes a two-way connection between the properties, ensuring that changes in one property are automatically reflected in the other and vice versa. This is a powerful feature for maintaining consistency between related properties.