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
How many java versions are there?
Why declare Main() inside the class in java ?
What do bitwise operators do?
What is flush () in java?
What is java regex?
Is it possible for a yielded thread to get chance for its execution again?
What is the difference between equals() and?
What is volatile keyword in java
What is byte value?
Explain the difference between association, aggregation and inheritance relationships.
what is the constructor and how many types of constructors are used in java?
What do you understand by private, protected and public?
When is the finally clause of a try-catch-finally statement executed?
What are the two ways to create a thread?
Is map ordered in java?