Multiple choice

Which of the following statement(s) is/are correct about volatile variables?

  1. These variables are used to save an object to a file.

  2. The thread will read the most recent updated value by using volatile variable.

  3. It is used to create variables and methods that will exist independently of any instances created for the class.

  4. Volatile variables are used in asynchronous medium.

  5. Both (2) and (4)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The volatile modifier always reconcile its own private copy of the variable with the master copy in memory.