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

Difference between java and javascript

0 Answers  


Is it possible to write JAVA program without including any of the packages,such as "import java.io.*"; bcoz I instantly wrote a code without "import..." statement and runned the program on command Line & it worked. the code is: class Person { String name; int age; Person(String s,int a) { name = s; age = a; } accept() { System.out.println(name+"Hi!!!!!"); System.out.println(age); } } class Demo { public static void main(Strings args[])throws IOException { String name = args[0]; int age = Integer.parseInt(args[1]); Person p = new Person(name,age); p.accept(); } }

3 Answers  


What is a conditional equation?

0 Answers  


Difference between vector and arraylist.

0 Answers  


What is temp in java?

0 Answers  






What is the difference between a local variable and an instance variable?

0 Answers  


What are abstract methods in java?

0 Answers  


How will you reverse a singly-link list?

0 Answers   Akamai Technologies,


In real time project which driver did u use? What is the main functionality of the Prepared Statement?

3 Answers   Photon,


What is void data type?

0 Answers  


What is the importance of main method in Java?

0 Answers  


How do you make an arraylist empty in java?

0 Answers  


Categories