What is the difference between static and global variables and also define what are volatile variables?



What is the difference between static and global variables and also define what are volatile variabl..

Answer / Ram Updesh Singh

Global variables belong to the class scope, while static variables belong to the class scope but can be accessed without creating an object of the class. Volatile variables in Java are used for variables that are modified by multiple threads. They ensure that the value is always up-to-date and thread-safe.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can we create constructor in abstract class ?

1 Answers  


What if static is removed from main method?

1 Answers  


What are void pointers?

2 Answers  


Can we declare an array without size in java?

1 Answers  


What do you mean by global variable?

1 Answers  


Can I overload to string method

1 Answers   UHG,


Is it possible to specify multiple jndi names when deploying an ejb?

1 Answers  


What is use of super keyword?

1 Answers  


What is immutability in java?

1 Answers  


What is finalize method?

1 Answers  


how to deploy apache tomcat server to weblogic server in java

1 Answers   IBM,


What best practices should you follow while writing multithreaded code in java?

1 Answers  


Categories