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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the polymorphism principle?

998


What do you mean by formatting?

990


What are the main uses of the super keyword?

964


How do you sort a set in java?

908


What is the difference between char and char *?

1071


Outline the major features of java.

1074


Differentiate between stringbuffer and string?

1022


What is diamond operator in java?

941


What is the difference between JDBC 1.0 and JDBC 2.0?

3175


Is it possible to specify multiple jndi names when deploying an ejb?

985


How to compare strings in java?

996


What is difference between filereader and bufferedreader?

948


Is singleton class immutable?

961


How to disable caching on back button of the browser?

1076


Is singleton thread safe in java?

965