Java OCA OCP Practice Question 1139

Question

What keyword is used to prevent an object from being serialized?

  • A. private
  • B. volatile
  • C. protected
  • D. transient
  • E. None of the above


D.

Note

By placing the keyword transient before an object's declaration, that value will not be included with the serialized data of the parent object.

For example,


class T{
   private transient int i;

}



PreviousNext

Related