Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What the hell is a serialized object?

 
Frank Wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my understanding,
1. A String, An Integer etc are serialized objects.
2. A class implements Serializable interface is an serialized object.
3. How about this: Is "A" a serialized class?
Class A {
String a;
SerializedClass B;
};

4. In java, when using a serialized object as a parameter, is it always pass by value?
The answer should be NO. Right?
Anybody can clear these for me?
Thanks,
John
 
Rajeev Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frank Wu
1-U should check the Java API. If Integer class has implemented a Serializable then it is serializable otherwise not.
2- A class which implements a Serializable interface produces serailizable object.
3- No this class is not Serializable
to make it serializable u should define it like this...
Class A implements Serializable
{
String a;
SerializedClass B;
}
4. In java, when using a serialized object as a parameter, is it always pass by value? ;
The answer to this question is YES!!!
But when u pass an object which has implemented Remote interface it is call by reference.
Bye
Raajeev
 
Frank Wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the below program
java.util.Vector implements Serializable, but is not pass by value!
/*
javap java.util.Vector;
public class java.util.Vector extends java.util.AbstractList implements java.util.List, java.lang.Cloneable, java.io.Serializable {
*/
public class jTest {
public static void change (Vector vec) {
vec.add("abc");
};

public static void main(String args[]) {
Vector v = new Vector();
System.out.println("len:" + v.size());
change(v);
System.out.println("len:" + v.size());
}
};

secadm@porpoise:/export/home/secadm/security> java jTest
len:0
len:1
 
Younes Essouabni
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So value or not???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic