Explain the difference between transient and volatile in java?



Explain the difference between transient and volatile in java?..

Answer / Anju

Transient is a keyword used to indicate that a variable should not be serialized. This means that when an object is serialized (converted into bytes), the transient variables will be ignored. Volatile, on the other hand, is a keyword used to indicate that a variable may be accessed by multiple threads and its value can change at any time. The JVM ensures that any thread reading the volatile variable always gets the most recent value.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Explain the features of interfaces in java?

1 Answers  


How do you use compareto in java?

1 Answers  


What is instance means in java?

1 Answers  


What are parent methods and how can you call them?

2 Answers  


how to write a program for chat function using core java

1 Answers   Satyam,


How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?

2 Answers  


Will minecraft java be discontinued?

1 Answers  


What is the static block?

1 Answers  


Why are there no global variables in java?

1 Answers  


Can we declare register variable as global?

1 Answers  


Why hashmap is used in java?

1 Answers  


What is difference between path and classpath?

1 Answers  


Categories