Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:19:20+00:00 2026-05-31T08:19:20+00:00

Suppose I serialize the below class (by putting a value to field x ,

  • 0

Suppose I serialize the below class (by putting a value to field x, say 5), and before doing the deserialization, I remove field x and put a new field y (int or float), what will be the result?

I believe deserialization is done successfully and value of field y will be default, is this correct?

If this is correct, where will the value if x will go in the transition from persistent object to stateful object at serialization time?

public class Cat implements Serializable{    
  private static final long serialVersionUID = 4231235177539824282L;  
  int x;
}

before deserialization:

public class Cat implements Serializable{    
  private static final long serialVersionUID = 4231235177539824282L;  
  float/int y;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:19:22+00:00Added an answer on May 31, 2026 at 8:19 am

    The serialization spec details the inner workings of field deserialization (you can find it here: http://docs.oracle.com/javase/7/docs/platform/serialization/spec/input.html)

    If you browse through the “readObject method” section it states:

    Any field of the object that does not appear in the stream is set to
    its default value. Values that appear in the stream, but not in the
    object, are discarded. This occurs primarily when a later version of a
    class has written additional fields that do not occur in the earlier
    version.

    So in essence, the field ‘x’ will have some value in the stream, but will be discarded and the field ‘y’ will be set to 0 (default value) since it does not appear in the stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have: public class foobar { public int lorem; public int ipsum; }
Let's suppose I have this object: [Serializable] public class MyClass { public int Age
Suppose i have one customer class and i will serialize the class to xml
Is it possible to serialize or deserialize any pointer? Suppose I have a class
Suppose I have string Name and Image Photo as properties of a class in
Suppose I have a list, in which no new nodes are added or deleted.
When I serialize an object, I can use the serialVersionUID mechanism at the class
I have a settings class that I want to be able to serialize and
Suppose I have the following class structure: [XmlInclude(typeof(CustomNode))] [XmlInclude(typeof(CustomNode2))] [XmlRoot(node)] class Node { [XmlElement(node)]
Suppose I have an application with the following code: public class Node { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.