Answer Posted / preetesh
There is no term as Global variable in Java.
Types of variable: 1) Local Variable declared within method.
2) Instance Variable declared within class but outside
method.
3) Class Variable
4) Parameters are also treated as variables
Example:
--------
public class Global {
public static int i = 25;
public static String s = "Preetesh";
}
//Such members can be accessed as:
public class Test {
public static void main(String[] args)
{
Global.i = Global.i + 100;
Global.s = "Java";
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is difference between float and double?
How is a structure different from array ?
Why java is a platform independent? Explain
Can a constructor call the constructor of parent class?
What do you mean by access modifier?
What is arrays fill in java?
What is the difference between stored procedure & function?
How concurrent hashmap works?
What is string intern in java?
How do you use compareto?
What is arraylist e?
Differentiate between nested and inner class in java.
How do you square a number in java?
How do you sort a set in java?
What is use of super keyword in java?