1.

Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?(a) transient(b) volatile(c) global(d) No modifier is neededI got this question in final exam.Enquiry is from Applets Fundamentals in division I/O & Applets of Java

Answer»

The correct option is (B) volatile

Easiest explanation: The volatile modifier TELLS the compiler that the variable modified by volatile can be changed unexpectedly by other part of the PROGRAM. Specially used in situations INVOLVING MULTITHREADING.



Discussion

No Comment Found

Related InterviewSolutions