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 indexof?
What is the difference between the ">>" and " >>>" operators in java?
Describe how to implement singleton design pattern in struts.
What is the difference between hashmap and hashtable? What is an interface?
Explain the difference between the public, private, final, protected, and default modifiers?
What is the difference between a switch statement and an if statement?
What is an object class?
What is the difference between heap memory and stack memory?
What are the restrictions imposed by a Security Manager on Applets?.
Is integer a class?
What happens when heap memory is full?
Can a main method be overloaded?
Is string thread safe in java?
What is type inference in java8?
Is age discrete or continuous?