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 are wrapped classes in java programming?
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example
Why declare Main() inside the class in java ?
What do you mean by byte code?
When we serialize an object does the serialization mechanism saves its references too?
what is predefined function in java?
What is an object's lock and which object's have locks in java programming?
Can we call the run() method instead of start()?
What flag up means?
why are wait(), notify() and notifyall() methods defined in the object class? : Java thread
What are different data types?
Is age discrete or continuous?
What is the difference between abstraction and encapsulation?
Is it possible for yielded thread to get chance for its execution again ?
How to find the largest value from the given array.