Q. What is the purpose of the ‘volatile’ keyword?

A
To make a variable thread-safe
B
To ensure a variable is read from main memory
C
To declare a variable as final
D
To prevent variable access
Solution:

Volatile ensures that a variable’s value is always read from and written to main memory in multithreaded contexts.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!