I have 2 objects inside one object(vector). how can i
serialize one of them. I dont want to serialize the second one

Answers were Sorted based on User's Feedback



I have 2 objects inside one object(vector). how can i serialize one of them. I dont want to serial..

Answer / atre sachin

suppose we are storing the two object of class A in Vector v1

class A implements serialiazable{
....
}

A a1=new A() //this will be the persist
transient A a2 =new A() //this will not persist because of the transient keyword.

now if I store the both a1 and a2 object in the vector v1 then we can achieve the goal given.
:-)

Is This Answer Correct ?    10 Yes 3 No

I have 2 objects inside one object(vector). how can i serialize one of them. I dont want to serial..

Answer / saroj kumar biswal

this answer is not correct. bcz java compiler will throw an error-illegal declaration of statement.check it out.

I think we will go for Externalizable interface. But the problem is how write the code inside writeExternal() & readExternal() methods

Is This Answer Correct ?    0 Yes 0 No

I have 2 objects inside one object(vector). how can i serialize one of them. I dont want to serial..

Answer / priya

yes we are able to done the above question by using
transient keyword

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Core Java Interview Questions

What is the synonym of procedure?

0 Answers  


what is different between static and non static methods ,using example

2 Answers  


java program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

7 Answers   HCL, Wipro,


How Vector class is synchronized,How to build user defined class as synchronized?

0 Answers  


What is an class?

0 Answers  






In which language java is written?

0 Answers  


In the HashMap, we know the values but we dont know the key, then how can we get the key from HashMap ?????

4 Answers   Kanbay,


wahts is mean by thread?

22 Answers   HCL, TCS,


Explain break statement and continue statement?

3 Answers  


What is subsequence of a string?

0 Answers  


What is the USE of Null interfaces ??...if thers nothing inside these interfaces how are they used and WHy are they used ???? No 1 has given a proper description yet

1 Answers  


What are the four versions of java?

0 Answers  


Categories