How will you override default serialization mechanism in java
Answer Posted / amit singh
you can inplements the Serialization interface for those
class you want to serailize
its marker interface its haven't any behaviour
but it indiacte that particular class is serializable
you can read and write particular object to convert in a
byte.
class Amit implements Serializable
{
Amit()
{
}
}
class B
{
public static void main(String []args)
{
Amit a = new Amit();
try{
}
catch{IoExcepton e)
{
}
try{
FileIntputStream f = new FileIntputStream("apoorva.txt")
OjectIntputStream o = new ObhjctInputStream(f);
o.ReadObject();
}
catch(IoException e)
{
}
}
thanks amit singh
amitsing2008@gmail.com
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is a class in java?
Why do we need singleton?
What is a parameter example?
1.IN CASE OF DYNAMIC METHOD DISPATCH WHY WE USE REFERENCE VARIABLE,WE CAN USE THE DIFFERENT DEFINED OBJECT DIRECTLY TO ACCESS THE DATA MEMBER AND MEMBER FUNCTION OF THAT RESPECTIVE CLASS?WHAT IS THE MAIN FUNCTION OF "REFERENCE VARIABLE" HERE?
What is immutable state?
What is the protected method modifier?
Convert a BST into a DLL and DLL to BST in place.
What is difference between filereader and bufferedreader?
What is the purpose of void class?
What is string pool in java?
What is gui programming?
How to split a string in java?
give an example for encapsulation?
a thread is runnable, how does that work? : Java thread
Can a class be protected in java?