What are the kinds of variables in Java? What are their uses?
Ans: Java has three kinds of variables namely, the instance variable, the local variable and the class variable. Local variables are used inside blocks as counters or in methods as temporary variables and are used to store information needed by a single method. Instance variables are used to define attributes or the state of a particular object and are used to store information needed by multiple methods in the objects. Class variables are global to a class and to all the instances of the class and are useful for communicating between different objects of all the same class or keeping track of global states.
Related Questions
- Our web sites uses Flash, Shockwave, Real Audio, CGI, Shopping Carts, Java or other cool stuff. Will this cause problems for the optimisation programme?
- How can my Java classes ask a template for information about its structure (e.g. a list of all the variables)?
- Why doesn JetStyle work with my source code that uses Java 1.5 language features?