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


Please Help Members By Posting Answers For Below Questions

How would you format a date in java? I.e. In the ddmmyyy format?

1065


What is square root in java?

762


How we can make copy of a java object?

839


What is the use of System class?

821


What is runtime locatable code?

1097






What is static variable with example?

746


whatis Home interface and Remoteinterface? with example?

1718


What is used of static keyword in java?

751


Can the interface be final?

741


What is array pointers ?

780


What is an infinite loop? How infinite loop is declared?

763


What is the difference between yield() and sleep()?

736


Explain about the interpreter in java?

811


Give example to differentiate between call by value and call by reference.

766


How many threads does a core java have?

743