Java OCA OCP Practice Question 477

Question

Given the following class:

public class MyClass implements java.io.Serializable { 
     public int     iAmPublic; 
     private int    iAmPrivate; 
     static int     iAmStatic; 
     transient int  iAmTransient; 
     volatile int   iAmVolatile; 
     
       . . . 
} 

Assuming the class does not perform custom serialization, which fields are written when an instance of MyClass is serialized? (Choose all that apply.)

A.  iAmPublic 
B.  iAmPrivate 
C.  iAmStatic 
D.  iAmTransient 
E.  iAmVolatile 


A, B, E.

Note

Default serialization writes all non-static non-transient fields.




PreviousNext

Related