Serialization Deserialization & Externalization | Java Interview Questions and Answer | Code Decode
In this video of code decode core java we have covered serialization, deserialization and externalization
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
What is Serialization
Serialization is the conversion of a Java object into a static stream (sequence) of bytes, which we can then save to a database or transfer over a network.
Classes that are eligible for serialization need to implement a special marker interface, Serializable. The JVM allows special privileges to the class which implements the Serializable Interface.
Byte stream is platform-independent. This means that once you have a stream of bytes you can convert it into an object and run it on any kind of environment.
A class to be serialized successfully, two conditions must be met −
The class must implement the java.io.Serializable interface.
All of the fields in the class must be serializable. If a field is not serializable, it must be marked transient.
static fields belong to a class (as opposed to an object) and are not serialized
What is Deserialization
Deserialization is precisely the opposite of serialization. With deserialization, you start with a byte stream and re-create the object you previously serialized in its original state. However, you must have the definition of the object to successfully re-create it.
FileInputStream fileIn = new FileInputStream("/tmp/employee.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
e = (Employee) in.readObject();
in.close();
fileIn.close();
What is Externalization?
Externalization in Java is used whenever you need to customize the serialization mechanism.
In serialization, the Java Virtual Machine is totally responsible for the process of writing and reading objects. This is useful in most cases, as the programmers do not have to care about the underlying details of the serialization process. However, the default serialization does not protect sensitive information such as passwords and credentials, or what if the programmers want to secure some information during the serialization process?
Thus externalization comes to give the programmers full control in reading and writing objects during serialization. JVM has no control over it. The complete serialization control goes to the application.
Based on our requirements, we can serialize either the whole data field or a piece of the data field using the externalizable interface which can help to improve the performance of the application.
Externalizable interface internaly extends Serializable interface
Externalizable interface is not a marker interface like Serializable interface. So, it provides two methods that are as follows:
void readExternal(ObjectInput inStream) - we call readExternal() method when we want to read an object’s fields from a stream. We need to write logic to read an object’s fields inside the readExternal() method. The readExternal() method throws IOException when an I/O error occurs. If the class of object being restored does not find, ClassNotException will be thrown.
void writeExternal(ObjectOutput outStream): writeExternal() method is used when we want to write an object’s fields to a stream. We need to write the logic to write data fields inside writeExternal() method. This method can throw an IOException when an I/O error occurs.
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
SQL Playlist : • SQL Interview Question...
GIT : • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
LinkedIn : / codedecodeyoutube
Instagram : / codedecode25
#singletondoublecheckedlocking #codedecode #javainterviewquestion
Пікірлер: 152
I still cannot understand why these videos have so less likes. These are best and fastest explanation of the concepts. And thank you so much All of your videos contain only pure content and there is no more butterring in any of the video. By watching your channel I have bagged an offer in one of the MNC.
@CodeDecode
Жыл бұрын
Many congratulations Naveen. Well deserved. Keep learning keep shining ⭐✨👍👍
@naveenkumarkandregula1605
Жыл бұрын
@@CodeDecode Thanks and Same to you.
@vinodsingh-zs7pb
Жыл бұрын
Uu i
@vinodsingh-zs7pb
Жыл бұрын
Oo ipoo
@rishiraj2548
Ай бұрын
❤️💯😎👍
Your channel is gradually becoming a sure shot recipe for cracking the toughest and trickiest Java interviews. Keep up the good work.
@CodeDecode
2 жыл бұрын
Thanks Sayan. Yeah we had this vision since start 🙂👍
One of the best tutorials I have come across in the recent times.very detailed explanation with examples.keep up the good work!!!
@CodeDecode
Жыл бұрын
Thanks Saranya 🙂🙂👍
After so many days, I got this concept clearly. Thanks!
@CodeDecode
8 ай бұрын
You’re welcome
Yes please add those videos as well..Very interesting and informative video..Thank you for this !!
@CodeDecode
Жыл бұрын
Thanks Divya 🙂🙂
Perfect video. Please share the next video. I just started watching your videos from last 2 days and learned so much. Thank you so much for all the efforts.
@CodeDecode
Жыл бұрын
Sure Aparna 👍👍🙂
Come daily mam, we want to hear your voice frequently. Thanks for the contribution and knowledge❤️
@CodeDecode
2 жыл бұрын
Thanks a lot Arpit. Sure we will try to be more frequent🙂🙂
Thanks for all this information about serialization at one place. Please do make a follow up video as well with much more in depth concepts
@CodeDecode
2 жыл бұрын
Thanks Vinod 🙂🙂sure 👍👍
I absolutely love your videos. It's a great channel for anyone who is preparing for interviews. Keep up the good work and wish you guys a successful future ahead. 💯💯
@CodeDecode
Жыл бұрын
Thanks a ton 😊👍
Very well, explained the entire concept. hats off!
@CodeDecode
Жыл бұрын
Thanks
A much needed video. Thank You Code Decode
@CodeDecode
2 жыл бұрын
Thanks Rushabh 🙂👍
Very good explanation . Thank you for this .This is called pure content
@CodeDecode
6 ай бұрын
Thanks Ashish 👍
All your interview questions videos are very useful for us, thank you ❤ for the great video
@CodeDecode
4 ай бұрын
Thanks for the nice words
Best best very best ❤❤❤❤ today I learn more about this topic thank you
@CodeDecode
2 жыл бұрын
Thanks Neha 🙂👍
@neha6000
2 жыл бұрын
@@CodeDecode no ma'am thank you for this usefull content
Thanks for the great explanation please bring the second part too asa soon as possible within 2-3 days...its help a lot...🙏🏻🙏🏻
@CodeDecode
Жыл бұрын
Sure Lalit 🙂👍
It's amazing explanation. Thanks for valuable knowledge. I learn many things from your video. Keep going up🙏😊
@CodeDecode
2 жыл бұрын
Thanks Sumit. Keep learning keep shining🙂🙂👍👍
Indeed cleanly explained and very knowledgeable thank you so much mam!!! Waiting for second part and would be more helpful if it is early☺☺
@CodeDecode
Жыл бұрын
Thanks Sachin. Sure 🙂👍
Best Explained mam... You will soon cross 1million mark... Language is easy, Keep it up...✌️👍
@CodeDecode
Жыл бұрын
Thanks a lot Amit 🙂🙂
Very nice today i have an interview ..i got confidence in this topic
@CodeDecode
2 жыл бұрын
All the best Jayaram 👍👍just keep your confidence up 👍👍
Good explanation. Please make the second part
@CodeDecode
2 жыл бұрын
Sure Akash 👍🙂
Thanks for detailed explanation, One of the best tutorial🙂
@CodeDecode
6 ай бұрын
Thanks
Great explanation. Please make the 2nd part of this video. Also please make detailed video on executor service, future, callable.
@CodeDecode
Жыл бұрын
Thanks Nikita. Sure 👍
@sheiksahil7209
Жыл бұрын
Yes ..please make a playlist on Executor Service Framework. It's a very hot topic for interviews nowadays. Thanks in advance
perfect explainstion maam , keep making deep videos.!
@CodeDecode
Жыл бұрын
Sure thanks Pankhudi 👍🙂
Perfect and Easy Explanation !!! very understandable
Great content and explanation , do create next part of this.
@CodeDecode
Жыл бұрын
Sure 👍👍🙂🙂
thanks for such great content..looking for the second part also
@CodeDecode
Жыл бұрын
sure nidhi we will create it soon
Thank you for such an amazing content... Keep doing the great work 👏
@CodeDecode
Жыл бұрын
Thanks Kishan 🙂👍
Thanks for the explanation, waiting for next video.
@CodeDecode
Жыл бұрын
Sure Shruti we will upload next part soon👍
The explanation is really very precise & clear.. Thank you so much ❤
Best video so far. Thank you mam. Like and subscribed. keep it up good work.
@CodeDecode
Жыл бұрын
Thanks Anand 🙂🙂
Thanks alot.. Nice explanation.. Keep it up. God bless you
@CodeDecode
Жыл бұрын
Thanks 🙂👍
Great. Thanks. Please make subsequent videos.
@CodeDecode
2 жыл бұрын
Sure👍🙂
Excellent explanation. Thanks a lot!
@CodeDecode
Жыл бұрын
You are welcome!
Great Explanation
@CodeDecode
8 ай бұрын
Thanks
Thanks for very well explanation 🙏🙏
@CodeDecode
Жыл бұрын
You're welcome shail
perfect perfect perfect perfect explanation, thank you very much and I'm going to subscribe you❤
@CodeDecode
11 ай бұрын
Thanks 😊
Finally after a long wait.... please do upload second part as well..and could you please also make some videos on microservice design patterns? Also, could you please let me know how an Eclipse workspace build can be triggered from eclipsec (not Eclipse GUI version) and also, does this way manage circular dependencies of the projects in the workspace? We are trying to automate the workspace setup since the application is very bulky. Just looking for some inputs.
@CodeDecode
Жыл бұрын
Sure. Yeh ms design patterns are in pipeline 🙂👍
Thank you so much!! Super explanation!!
@CodeDecode
11 ай бұрын
you're welcome
Maybe I am late, but it was a great video and would love to learn further on this.
@CodeDecode
Жыл бұрын
Thanks Akash 🙂🙂
Your an inspiration for me :)
@CodeDecode
Жыл бұрын
And you guys are motivation for us❤️❤️. Your comments for love makes all these hard work all worth it !! Thanks for being irreplaceable part of our code decode family
@uvanana.
Жыл бұрын
@@CodeDecode ❤️❤️
Back to basics. Please hold it for long ❤️❤️
@CodeDecode
Жыл бұрын
sure
With content full and good explanation madam have a great time 😊😊🙂🙂
@CodeDecode
Жыл бұрын
Thanks 🙂🙂👍👍
@kedarnathanubolu2295
Жыл бұрын
@@CodeDecode plz make vedio on collection madam
@CodeDecode
Жыл бұрын
kzread.info/dash/bejne/fZqjsLuohrioeqw.html
very good explanation. please upload the second part.
@CodeDecode
2 жыл бұрын
Sure thanks 🙂👍
Thanks a ton! Clearly explained
@CodeDecode
2 жыл бұрын
Thanks Sibin 🙂👍
Thanks for such an amazing content
@CodeDecode
Жыл бұрын
You're welcome dhruv
really thanks! for this much hard work 🙂
Greatnesssssssssssssssssss best teaching thank you
@CodeDecode
Жыл бұрын
Thanks harshwardhan
Thanku so much mam.
@CodeDecode
Жыл бұрын
You're welcome
Need role based authentication video
@CodeDecode
Жыл бұрын
Sure 👍👍
Very good explanation. Can you please make detail video on multithreading w.r.t to executor service,future,callable and interview question asked on these topic
@CodeDecode
Жыл бұрын
Sure Pranjal. It's in pipeline 🙂🙂
Please share me one session of locking mechanism and its usage in multi thread invironment
Please make video on junit mokito....
Thanks for making video on this topic And also make interview questions video on Multi threading
@CodeDecode
2 жыл бұрын
Sure 👍🙂🙂
One doubt if we are using hibernate then we can simply save our object into data base by calling session.save(obj) and this obj class need not to implements Serializable. Please help with this.
As expected 👌
@CodeDecode
2 жыл бұрын
Thanks Sairam 🙂🙂
Thank you mam! Can you please make video on how to prevent a java deserilize vulnerability...
@CodeDecode
2 жыл бұрын
Sure Vithal 🙂👍
Thank you!!!
@CodeDecode
4 ай бұрын
You're welcome!
Mam may i know if microservice can call monolithic service? Example: if an application having microservices and they are not maintaing any database. So they have to consume another project service(Monolithic) and with their respone, we have to manuplate at our end and send response to the end users.
I am pretty new to this concept. I always have a query. In DB data is stored in rows and columns as user input and it is in readable format. But why do we say object is converted to byte stream and stored in DB ?
@CodeDecode
Жыл бұрын
No problem Teja. Initially these doubts are bound to pop up in our mind. Good thing is that you are trying to clarify that👍👍. So first of all not all databases are rows and columns. These are relational dbs you are thinking about. There are many many many others available out in marker like no sql dbs like table db, like casandra etc etc. And second misconception here, not all objects in java are pojos. Even images, blobs, documents all these are objects too that we need to store in db. These have to converrd to bytes stream b4 storing them
@tejachowdary309
Жыл бұрын
@@CodeDecode thank you for making me understand. So non relational db’s use this for storing images , pdfs etc ? Relational db like sql doesn’t need this right
Serialize/Deserialize with in java, than what is the use of Jackson/Gson API.
Please make your videos in high quality(HD).
@CodeDecode
Жыл бұрын
Hey Robin we have uploaded all our latest videos in high quality
Thanks!!!
@CodeDecode
Ай бұрын
You’re Welcome!
please create the second part.
@CodeDecode
Жыл бұрын
Sure we will create it soon
Kindly add second part of the video 🙏
@CodeDecode
Жыл бұрын
Sure 👍👍
Hi can you please take one vedio consuming webservice using webclient and mono and flux .
@CodeDecode
Жыл бұрын
Sure Raju 🙂👍
Yes we need it
👌
@CodeDecode
Жыл бұрын
🙂🙂
Pls second part😊😊😊😊
@CodeDecode
Жыл бұрын
sure we will create it soon
Thanks
@CodeDecode
2 жыл бұрын
🙂🙂
please make a video on the second part
@CodeDecode
Жыл бұрын
Sure we will create video soon on it
We want next video
@CodeDecode
Жыл бұрын
Sure Neelesh 🙂🙂
🙏🙏👍✌
@CodeDecode
2 жыл бұрын
🙂🙂
can you please give these slides ?
Please do videos on Spring boot
@CodeDecode
2 жыл бұрын
kzread.info/head/PLyHJZXNdCXsdXxY8wupiLenux2Yafn1lN
@priyanka0879
2 жыл бұрын
@@CodeDecode thanks for your response
memorize from @ 19:56
Speed 1x = 2x
@CodeDecode
3 ай бұрын
We will reduce 😊