Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an interface extend the Serializable interface?

Tags:

Is it possible to create an interface extending the Serializable interface?

If yes, will that extended interface behave like the Serilizable interface? If not, why?

like image 836
GuruKulki Avatar asked Feb 16 '10 13:02

GuruKulki


People also ask

Can an interface extend?

An interface can extend other interfaces, just as a class subclass or extend another class. However, whereas a class can extend only one other class, an interface can extend any number of interfaces. The interface declaration includes a comma-separated list of all the interfaces that it extends.

Can you make an interface Serializable in Java?

Serializable in Java If you want a class object to be serializable, all you need to do it implement the java. io. Serializable interface. Serializable in java is a marker interface and has no fields or methods to implement.

Which interface is used for serialization?

A particular type of marker interface, “Serializable,” is implemented for the serialization process. So, the classes eligible for serialization, i.e., the serializable class in Java, should implement the marker interface. This mechanism of writing an object state into a stream of bytes is known as serialization.

What is true about Serializable interface in Java?

Explanation: Serializable interface does not have any method. It is also called a marker interface.


1 Answers

Yes, you can extend the Serializable interface. If you do, all classes that implement the new subinterface will also be implementing Serializable.

like image 104
akf Avatar answered Oct 14 '22 00:10

akf