Multiple choice technology programming languages

Which Interface has no methods.

  1. Servlet

  2. Runnable

  3. Serializable

  4. ActionListener

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The Serializable interface in Java is a marker interface with no methods. It serves only to indicate that a class can be serialized - the actual serialization is handled by the JVM. Interfaces like Runnable, Servlet, and ActionListener all declare methods that must be implemented.

AI explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Servlet - This option is incorrect. The Servlet interface in Java has several methods, such as init(), service(), and destroy(), which are used to handle HTTP requests and responses.

Option B) Runnable - This option is incorrect. The Runnable interface in Java has a single method called run(), which is used to define the code that will be executed in a separate thread.

Option C) Serializable - This option is correct. The Serializable interface in Java is a marker interface, which means it does not have any methods defined in it. It is used to indicate that a class can be serialized, i.e., its objects can be converted into a stream of bytes for storage or transmission.

Option D) ActionListener - This option is incorrect. The ActionListener interface in Java has a single method called actionPerformed(), which is used to handle action events, such as button clicks or menu selections.

The correct answer is C) Serializable. This option is correct because the Serializable interface does not have any methods defined in it.