UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Is there any difference between Serializalble and Externalizable interface?

Asked by Last Modified  

10 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Senior Software Engineer

1. In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. 2. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing...
read more
1. In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. 2. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing objects into persistence. 3. Externalizable interface provides complete control of serialization process to application. 4. readExternal() and writeExternal() supersede any specific implementation of writeObject and readObject methods. read less
Comments

Expert in Java/J2ee technology

Serializable Interface has its own standard protocol to implement serialization capability. But implementing Externalizable interface developer needs to implement writeExternal and readExternal methods. Externalizable extends Serializable.
Comments

B.E. (IT)

by implementating java.io.Serializable, you get "automatic" serialization capability for objects of your class. No need to implement any other logic, it'll just work. The Java runtime will use reflection to figure out how to marshal and unmarshal your objects. In earlier version of Java, reflection...
read more
by implementating java.io.Serializable, you get "automatic" serialization capability for objects of your class. No need to implement any other logic, it'll just work. The Java runtime will use reflection to figure out how to marshal and unmarshal your objects. In earlier version of Java, reflection was very slow, and so serializaing large object graphs (e.g. in client-server RMI applications) was a bit of a performance problem. To handle this situation, the java.io.Externalizable interface was provided, which is like java.io.Serializable but with custom-written mechanisms to perform the marshalling and unmarshalling functions (you need to implement readExternal and writeExternal methods on your class). This gives you the means to get around the reflection performance bottleneck. In recent versions of Java (1.3 onwards, certainly) the performance of reflection is vastly better than it used to be, and so this is much less of a problem. I suspect you'd be hard-pressed to get a meaningful benefit from Externalizable with a modern JVM. Also, the built-in Java serialization mechanism isn't the only one, you can get third-party replacements, such as JBoss Serialization, which is considerably quicker, and is a drop-in replacement for the default. A big downside of Externalizable is that you have to maintain this logic yourself - if you add, remove or change a field in your class, you have to change your writeExternal/readExternal methods to account for it. In summary, Externalizable is a relic of the Java 1.1 days. There's really no need for it any more. read less
Comments

Senior Software Engineer

To add to the other answers, by implementating java.io.Serializable, you get "automatic" serialization capability for objects of your class. No need to implement any other logic, it'll just work. The Java runtime will use reflection to figure out how to marshal and unmarshal your objects.
Comments

Java Trainer

Serializable provides default serialization(takes care by JVM) whereas Externalizable is used for customized serialization(Everything takes care by the programmer. When we implement Serializable interface , total object is saved but in case of Externalizable, programmer can save total object or part...
read more
Serializable provides default serialization(takes care by JVM) whereas Externalizable is used for customized serialization(Everything takes care by the programmer. When we implement Serializable interface , total object is saved but in case of Externalizable, programmer can save total object or part of the object. Serializable is a marker interface(does not contain any method whereas Externalizable contains writeExternal() and realExternal() methods. read less
Comments

Difference between Externalizable and Serializable In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe...
read more
Difference between Externalizable and Serializable In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing objects into persistence. Externalizable interface provides complete control of serialization process to application. readExternal() and writeExternal() supersede any specific implementation of writeObject and readObject methods. Though Externalizable provides complete control, it also presents challenges to serialize super type state and take care of default values in case of transient variable and static variables in Java. If used correctly Externalizable interface can improve performance of serialization process. read less
Comments

Trainer

Serializalble is a marker interface, where as Externalizable is a interface, contains two methods writeExternal() and readExternal(). Externalizable interface is fast and also consumes less memory. Serializable involves reflection mechanism to recover the object. A public no-arg constructor is needed...
read more
Serializalble is a marker interface, where as Externalizable is a interface, contains two methods writeExternal() and readExternal(). Externalizable interface is fast and also consumes less memory. Serializable involves reflection mechanism to recover the object. A public no-arg constructor is needed while using Externalizable interface but in Serializable it reads the required information from the ObjectInputStream and this is why it uses reflection mechanism. read less
Comments

Computer Trainer

Serializable Interface is based on a recursive algorithm i.e during the serialization besides the fields it will serialize all the objects that can be reached through its instance variables i.e. all the objects that can be reached from that object (provided that all the classes must implement Serializable...
read more
Serializable Interface is based on a recursive algorithm i.e during the serialization besides the fields it will serialize all the objects that can be reached through its instance variables i.e. all the objects that can be reached from that object (provided that all the classes must implement Serializable Interface). This includes the super class of the object until it reaches the “Object” class and the same way the super class of the instance variables until it reaches the “Object” class of those variables. Basically all the objects that it can read. And this leads to a lot of overhead when we want to save only few variable or a small data as compared to the class For eg – If you have a class named Mercedes and you just want to store the car series and its car identification number then you can not stop at this only and will have to store all the fields of that class and also of its super class(if exists and implements serializable interface) and a lot more. Serializable is a marker interface and hence no need to override any method and whenever there is any change in the entity or bean classes you just need to recompile your program whether in the case of Externalizable interface you have to implement writeExternal() and readExternal() methods which contains the logic to store and retrieve data and with changes you might need to do changes in the code logic. Serializable provides you both options i.e. you can handle the process by your own or you can leave it for the process to be done in the default way but in Externalizable you have to provide the logic of the process and have full control over the serialize and deserialize process. Serializable involves reflection mechanism to recover the object. This also adds the the metadata i.e. class description, variable information etc of all the serializable classes in the process which adds a lot of data and metadata into the stream and consumes bandwidth and a performance issue. A public no-arg constructor is needed while using Externalizable interface but in Serializable it reads the required information from the ObjectInputStream and this is why it uses reflection mechanism. You need to define serialVersionUID in case of Serializable and if it is not explicitly defined it will be generated automatically and it is based on all the fields, methods etc of the class and it changes every time you do the changes in the class. You if current id does not match with generated id you will not be able to recover the previously stored data. Since the ID is generated every time it will take considerable amount of time which is not a case with externalizable interface. Externalizable interface is fast and also consumes less memory as compared to the other one. read less
Comments

http://www.codingeek.com/java/io/differences-serializable-externalizable-interface-java-tutorial
Comments

Trainer

1. In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. 2. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing objects...
read more
1. In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application. 2. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing objects into persistence. 3. Externalizable interface provides complete control of serialization process to application. 4. readExternal() and writeExternal() supersede any specific implementation of writeObject and readObject methods. Though Externalizable provides complete control, it also presents challenges to serialize super type state and take care of default values in case of transient variable and static variables in Java. If used correctly Externalizable interface can improve performance of serialization process. read less
Comments

View 8 more Answers

Related Questions

Is Java a pure object-oriented programming language?
Java language is not a Pure Object Oriented Language as it contain these properties: Primitive Data Type ex.
Shiv
0 0
5
Hi, We provide online instructor-led training. I am looking for Java Teacher/Instructor who can teach java via online. If anyone interested then contact me. I have to start the class from tomorrow onwards.
Hi, If you haven't finalised yet, I am interested in being an instructor. I will be teaching the newest version of Java, Java 10. Experience - 3 yrs as Software Engineer, BTech CSE, teaching Java to school and college students since 3 yrs.
Ujjwal Rana
What are the advance features in java 1.8 when compare to java 1.6?
Many are there. 1. Lambda expression (functional Programming). 2. Default methods in interfaces.
Naresh N
Does Java support pointers?
Yes and no. . The pointer model is of course supported by Java. But it has become much easier to the developer to handle it. Because Java exposes the concept of pointer in terms of reference variables...
Santosh
0 0
7
What are the advantages of learning Java?
Dear Niteen Java is one of the most widest implemented technology for programming. Not only its used to develop full fledged Software Applications, but its also used for programming devices like Set...
Niteen
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

CoreJAVA
Core Java Training High Level Course Content Trained by Java Architect 1. Core Java Programming Introduction of Java 2. Data types and Operators 3. Control Flow statements 4. OOPS and its application...
A

Java Learning Tip
The easy way to learn any programatical language is just simple practices. Take a simple examples and practice daily one hour. And also go through the learning videos from youtube or somewhere else.

Use of Service Locator Pattern
If we want to reuse the java code that should be the best approach w.r.t re-usability, maintanence and saving time to concentrate on our own businbess logic/requirement. In the similar approach many patterns...
M

Differences Between HashMap vs HashSet In Java.
HashSet HashMap HashSet implements Set interface. HashMap implements Map interface. HashSet stores the data as objects. HashMap stores the data as key-value pairs. HashSet...

Java Training Syllabus
Learn JAVA-J2EE Syllabus Core Java - Syllabus aligned to OCA Exam - JDK 8 Object-Oriented Programming (OOPS) concepts: Programming Languages Object Oriented Programming Classes & Objects Pillars...

Recommended Articles

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more