What are Transient and Volatile Modifiers?
Answer Posted / harika.thota001@gmail.com
we can use volatile in the application where a lot of threads are working simultaneously. Each thread having its local copy for instance variable. If we use volatile then it will become master copy. All will access the master copy. so whatever is latest we can use.
While Transient is used in the case of serialization.
Serialization is a process of writing an object in the files.
if we use prefix transient with variable than that variable value will not store when we write the object in the file.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is array size in java?
How dead lock situation occurs in java and how you can identify it?
Can we use String with switch case?
What's the difference between int and integer in java?
What are examples of modifiers?
What are user defined exceptions?
What is classpath?
How many ways can we create the string object?
What is the size of int in 64-bit jvm?
What is a concrete classes? Is Java object class is concrete class?
How do you take thread dump in java?
What is the method overriding?
How do you compare values in java?
What is the use of flag?
When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?