Explain Global variables in Packages?
Answers were Sorted based on User's Feedback
Answer / milind
i think der is no such thing global variable in java....
instance variable
local vaiable is in java
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
Answer / anitha
expect private,all public,protected and default variables
are global in a package
Is This Answer Correct ? | 0 Yes | 1 No |
How many threads does a core java have?
How is treeset implemented in java?
Can a main method be declared final?
Explain Event handling in AWT?
Why const and goto are reserved keyword in java?
What's the default access specifier for variables and methods of a class?
What is a consumer in java?
Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?
Can we sort set in java?
Can Exception handling we can handle multiple catch blocks?
What is the difference between size and length in java?
What is primitive data type in java?