What is Transient and volatile

Answer Posted / sudhadevi

Transient
~~~~~~~~~
identifies a variable not to be written out when
an instance is serialized (It can'nt be copied to remove
system)

Volatile
~~~~~~~~
indicates that the field is used by synchronized
threads and that the compiler should not attempt to perform
optimizations with it.When more than one thread share a
(volatile) data it is checked every time. Every thread
keeps the latest value of volatile variable

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we override singleton class?

538


What is difference between final and immutable?

561


What is the purpose of declaring a variable as final?

486


What is default switch case? Give example.

578


how we can use debug in myeclipse 6.0 in order solve the problems that exist in our program when there are 900 to 1000 pages in a web application

1668






How do you write a scanner class in java?

568


What does indexof mean?

537


What is ++ a in java?

570


What does exp mean in math?

535


What are the parts of methodology?

549


What are the three types of design patterns?

519


What is the main use of generics in java?

510


Can we sort array in java?

531


How to stop a thread in java? Explain about sleep () method in a thread?

584


Is oracle java 11 free?

533