How can you avoid serialization in child class if the base class is implementing the serializable interface?



How can you avoid serialization in child class if the base class is implementing the serializable in..

Answer / Prabhakar Awasthi

"By declaring the constructor of the child class as private, you can prevent the creation of new instances from outside the class. Since constructors are not inherited in Java, the child class will not be serialized even if its superclass implements Serializable."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Tell us something about different types of casting?

1 Answers  


when you will synchronize a piece of your code? : Java thread

1 Answers  


Is &&= a valid Java operator?

2 Answers  


how to convert Java project into Maven ?

1 Answers   Infosys,


please tell me what is wrapper class in java with example ?

6 Answers   HP,


Explain the difference between an object-oriented programming language and object-based programming language?

1 Answers  


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

1 Answers  


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

3 Answers   Photon,


What is an example of a boolean?

1 Answers  


What is the preferred size of a component?

3 Answers   ITSA,


Explain the difference between abstract class and interface in java?

1 Answers  


Describe the process as to how substring() methodology mechanisms in java.

1 Answers  


Categories