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

Can a class have multiple superclasses?

0 Answers  


what is difference between signed & unsigned char?

2 Answers  


What do you mean by hashing?

0 Answers   Amazon,


Mention some features of java?

0 Answers  


What is application tier?

0 Answers  


What is boolean logic?

0 Answers  


Explain how to force the garbage collection in java.

0 Answers  


What is the type of lambda expression?

0 Answers  


what is webservices?

1 Answers   CTS, Ericsson, HCL,


What is the difference between static synchronize() metod and synchronize() method?

1 Answers   Polaris,


JSP is by default thread safe or not? what is the meaning of isThreadSafe="true" and isThreadSafe="false". Explain it? Thanks, Seenu

9 Answers   Huawei,


What is casting ?

2 Answers  


Categories