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 |
In Java why we write public static void main(String args[]) why not main()?
46 Answers Aptech, GE Healthcare, Infosys, Microsoft, New Horizon, Practical Viva Questions, TCS, Wipro,
How Vector class is synchronized,How to build user defined class as synchronized?
why java does not support multiple inheritance
41 Answers Diamond, Euclid, Evergent, KLKJ, Mind Tree, NIIT, SSI Small Scale Industries, Wipro,
What if static is removed from main method?
Which package has light weight components?
What is a method signature java?
why operator overloading is removed in java?
Can we start a thread twice in java?
Which is best ide for java?
Which variables are stored in stack?
Write a program to check for a prime number in java?
What is difference between ++ I and I ++ in java?