Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the need to implement Serializable interface (with
no methods) for objects which are to be serialized ?
We can write our own functionality which writes objects to
streams then why we need to implement and tell JVM that
which objects can be serialized.

Answers were Sorted based on User's Feedback



What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / chellammal

Implementing Serializable interface signifies that the
object can be persisted. Otherwise, when you try to
use writeObject, it will throw
java.io.NotSerializableException

Is This Answer Correct ?    15 Yes 2 No

What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / rohit

Serializable concept is related with the state persisitence
of the object.
Example:---
When u send the some object on internet it needs to be
serialized bcz before sending the object it first converted
in to byte & desrerialization is the process is used to get
it back in its original form

Is This Answer Correct ?    6 Yes 1 No

What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / akj504

Ya that answers are expected but...
If we open ObjectOutputStream.java (which is used for
serialization) then we see the following code :

............................
writeObject0(Object obj, boolean unshared){
.............
} else if (cl.isArray()) {
writeArray(obj, desc, unshared);
} else if (obj instanceof Serializable) {
writeOrdinaryObject(obj, desc, unshared);
} else {
throw new NotSerializableException(cl.getName());
}
................

If we remove the checking instanceof (& recompile) or if we
override the writeObject0 method then
Will it still check whethere the class has implemented
serilizable ?

Is This Answer Correct ?    1 Yes 1 No

What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / dbin

The problem with your own functionality is with deserialization process , when reconstructing the new objects that are equal to the objects you are trying to save....

Is This Answer Correct ?    0 Yes 0 No

What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / aman kr aggarwal

well if we dont use Serializable interface which is a
marker interface, then the object which we want to
serialize and use writeObject() method then compiler would
throw exception as if other object which r related to that
object if not serialized.
So. to overcome this we have to use Seializable interface.

Is This Answer Correct ?    3 Yes 6 No

What is the need to implement Serializable interface (with no methods) for objects which are to be ..

Answer / th

Serializable is used

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More Core Java Interview Questions

is it possible to add a object in a HASHMAP

6 Answers   HCL,


Why string objects are immutable in java?

0 Answers  


Can an interface have a constructor?

0 Answers  


How to create packages in java?

0 Answers  


What are the drawbacks of singleton class?

0 Answers  


What is local class in java?

0 Answers  


Give the difference between the println method and sqrt method?

0 Answers  


what is the difference between preemptive scheduling and time slicing? : Java thread

0 Answers  


System.out.println("somestring"); It will create any object or not

5 Answers   CSC,


Can a class have multiple superclasses?

0 Answers  


What does math floor () do?

0 Answers  


Where is jre installed?

0 Answers  


Categories