SlideShare a Scribd company logo
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
ADVANTAGES AND DISADVANTAGES
HOW DO WE SERIALIZE AN OBJECT?
WHY DO WE NEED SERIALIZATION?
WHAT IS SERIALIZATION?
CONTROVERSIES ON SERIALIZATION
BEST PRACTICES
WHAT IS SERIALIZATION?
www.edureka.co
JVM-1 JVM-2
Byte Stream
Object Object
Byte Stream
WHAT IS SERIALIZATION?
www.edureka.co
www.edureka.co
Serialization in Java is the process of converting the Java code
Object into a Byte Stream, to transfer the Object Code from one
Java Virtual machine to another and recreate it using the process
of Deserialization.
WHY DO WE NEED SERIALIZATION?
www.edureka.co
WHY DO WE NEED SERIALIZATION?
Persistence
Deep Copy
Caching
Cross JVM Synchronization
Communication
www.edureka.co
HOW DO WE SERIALIZE AN OBJECT?
www.edureka.co
www.edureka.co
To Serialize an object, the parent class should implement
either of the following interfaces:
‱ java.io.Serializable
‱ java.io.Externalizable
HOW DO WE SERIALIZE AN OBJECT?
ADVANTAGES AND DISADVANTAGES
www.edureka.co
ADVANTAGES
‱ Serialization process does not require third-party
software.
‱ The Serialization procedure is simple .
‱ Serialization procedure is universal .
‱ It is easy to use and simple to customize.
‱ Serialized data streams support Encryption,
Compression, Authentication and secure Java
computing.
‱ Many critical technologies relying on serialization.
www.edureka.co
DISADVANTAGES
‱ Objects while Deserialization becomes brittle.
‱ Serialization results in the failure in the initialization of
transient variables resulting in a variation to the
Standard Java Flow.
‱ Serialization is inefficient in terms of memory
utilization.
‱ Serialization does not offer any transition control
mechanism per every SE.
‱ Serialization procedure fails to offer fine-grained
control to access Objects.
www.edureka.co
PRACTICAL EXAMPLES
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
SERIALIZATION USING INHERITANCE
CASE - 1
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
SERIALIZATION USING INHERITANCE
CASE - 2
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
SERIALIZATION USING INHERITANCE
CASE - 3
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
SERIALIZATION USING A
STATIC MEMBER
www.edureka.co
EXTERNALIZABLE INTERFACE
www.edureka.co
Implementation
Methods
Process Public No-Arg Constructor
Backward Compatibility
EXTERNALIZABLE INTERFACE
www.edureka.co
www.edureka.co
‱ While using Externalizable Interface the user
explicitly mentions the objects to be serialized.
‱ In Serialization Interface, all the objects and variables are
serialized in the run-time.
IMPLEMENTATION
www.edureka.co
‱ Externalizable interface consists of two methods, namely:
writeExternal()
readExternal()
‱ Serializable Interface does not include any methods.
METHODS
www.edureka.co
‱ Externalizable Interface provides customization to the
Serialization process.
‱ Serialization Interface will provide the default serialization
process.
PROCESS
www.edureka.co
‱ Externalizable Interface supports Serialization
regardless of the version control.
‱ Serialization Interface requires the same version of
JVMs on both the ends, but it incorporates automatic
serialization.
BACKWARD COMPATABILITY
www.edureka.co
‱ Externalization Interface needs Public No-Arg Constructor to
reconstruct the serialized object.
‱ Serialization Interface uses reflection to reconstruct the
serialized object or class.
PUBLIC NO-ARG CONSTRUCTOR
TRANSIENT KEYWORD
www.edureka.co
www.edureka.co
TRANSIENT KEYWORD
Transient Keyword
www.edureka.co
www.edureka.co
TRANSIENT KEYWORD
Transient Keyword
Transient Keyword is used as a variable modifier at the time of
the Serialization process. Declaring a variable with transient
keyword avoids the variable from being Serialized.
TRANSIENTKEYWORD
SERIAL VERSION UID
www.edureka.co
www.edureka.co
SERIAL VERSION UID
Serializable objects get associated with a unique identification
number provided by the JVM of the host machine. This Unique
ID is called Serial Version UID.
SERIALVERSIONUID
CONTROVERSIES ON SERIALIZATION
www.edureka.co
www.edureka.co
WHAT IS AN INHERITANCE?
Oracle’s Architects intend to remove Serialization from Java as
they consider it as a Horrible Mistake of 1997.
After hectic research, the developers at Oracle found out a few
flaws in the design of Serialization procedure which pose a
threat to the data.
BEST PRACTICES
www.edureka.co
BEST PRACTICES
‱ It is recommended use javadoc@ serial tag for
denoting Serializable fields.
‱ The .ser extension is preferred to be used for files
representing serialized objects.
‱ It is not recommended for any static or transient
fields to undergo default serialization.
‱ Extendable classes should not be Serialized unless it
is mandatory.
‱ Inner Classes should be avoided to be involved in
Serialization.
www.edureka.co
What is Serialization in Java? | Java Tutorial | Edureka
www.edureka.co

More Related Content

What's hot (20)

PPTX
String Builder & String Buffer (Java Programming)
Anwar Hasan Shuvo
 
PPTX
MULTI THREADING IN JAVA
VINOTH R
 
PPTX
Css selectors
Parth Trivedi
 
PDF
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
PDF
Arrays in Java
Naz Abdalla
 
PPT
Java collections concept
kumar gaurav
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PPTX
Constructor in java
SIVASHANKARIRAJAN
 
PPTX
This keyword in java
Hitesh Kumar
 
PPTX
Python dictionary
Mohammed Sikander
 
PDF
C++ OOPS Concept
Boopathi K
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPS
String and string buffer
kamal kotecha
 
PPTX
Multithreading in java
Monika Mishra
 
PDF
Set methods in python
deepalishinkar1
 
PPTX
single linked list
Sathasivam Rangasamy
 
PPTX
this keyword in Java.pptx
ParvizMirzayev2
 
PDF
Java IO
UTSAB NEUPANE
 
PPTX
Control statements in java
Madishetty Prathibha
 
String Builder & String Buffer (Java Programming)
Anwar Hasan Shuvo
 
MULTI THREADING IN JAVA
VINOTH R
 
Css selectors
Parth Trivedi
 
Chapter2 Encapsulation (Java)
Dyah Fajar Nur Rohmah
 
Arrays in Java
Naz Abdalla
 
Java collections concept
kumar gaurav
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
Constructor in java
SIVASHANKARIRAJAN
 
This keyword in java
Hitesh Kumar
 
Python dictionary
Mohammed Sikander
 
C++ OOPS Concept
Boopathi K
 
Exception Handling in Java
lalithambiga kamaraj
 
String and string buffer
kamal kotecha
 
Multithreading in java
Monika Mishra
 
Set methods in python
deepalishinkar1
 
single linked list
Sathasivam Rangasamy
 
this keyword in Java.pptx
ParvizMirzayev2
 
Java IO
UTSAB NEUPANE
 
Control statements in java
Madishetty Prathibha
 

Similar to What is Serialization in Java? | Java Tutorial | Edureka (20)

PDF
Building Concurrent WebObjects applications with Scala
WO Community
 
PPTX
Insecure Java Deserialization
Shiv Sahni
 
PPT
13243967
vijayabharati
 
PPTX
Design patterns
Alok Guha
 
PDF
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
10322210023
 
PDF
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
PDF
Java programming and security
UmeshchandraYadav5
 
PDF
BarcelonaJUG - Revolutionize Java Database Application Development with React...
Juarez Junior
 
PDF
How Java 19 Influences the Future of Your High-Scale Applications .pdf
Ana-Maria Mihalceanu
 
PDF
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
Juarez Junior
 
PDF
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Juarez Junior
 
PPTX
P20CSP105-AdvJavaProg.pptx
DrTCVijayaraghavan
 
PPTX
Java serialization
Sujit Kumar
 
PDF
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
Juarez Junior
 
PPTX
Advance java1.1
Prince Soni
 
PPTX
Introduction to React native
Dhaval Barot
 
PPTX
JavaScript, VBScript, AJAX, CGI
Aashish Jain
 
PPT
Spring - a framework written by developers
MarcioSoaresPereira1
 
PPT
Gnizr Architecture (for developers)
hchen1
 
PDF
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
Juarez Junior
 
Building Concurrent WebObjects applications with Scala
WO Community
 
Insecure Java Deserialization
Shiv Sahni
 
13243967
vijayabharati
 
Design patterns
Alok Guha
 
1. JAVA_Module_1-edited - AJIN ABRAHAM.pptx.pdf
10322210023
 
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
Java programming and security
UmeshchandraYadav5
 
BarcelonaJUG - Revolutionize Java Database Application Development with React...
Juarez Junior
 
How Java 19 Influences the Future of Your High-Scale Applications .pdf
Ana-Maria Mihalceanu
 
Andersen_Revolutionize Java DB AppDev with Reactive Streams and Virtual Threa...
Juarez Junior
 
Porto Tech Hub Conference 2023 - Revolutionize Java DB AppDev with Reactive S...
Juarez Junior
 
P20CSP105-AdvJavaProg.pptx
DrTCVijayaraghavan
 
Java serialization
Sujit Kumar
 
DWX23 - Revolutionize Java DB AppDev with Reactive Streams and Virtual Threads
Juarez Junior
 
Advance java1.1
Prince Soni
 
Introduction to React native
Dhaval Barot
 
JavaScript, VBScript, AJAX, CGI
Aashish Jain
 
Spring - a framework written by developers
MarcioSoaresPereira1
 
Gnizr Architecture (for developers)
hchen1
 
CloudLand - Revolutionize Java DB AppDev with Reactive Streams and Virtual Th...
Juarez Junior
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 
Ad

Recently uploaded (20)

PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 

What is Serialization in Java? | Java Tutorial | Edureka