Explain about global variables in Java?
Answers were Sorted based on User's Feedback
Answer / ravikiran(aptech mumbai)
global variables are declared globally and not inside any
method.
They are applicable to all the parts of the class
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / satish
Direct global variables are not possible like
int i=0;
class{
....
....
}
But other way is create a class with static variables and
you can use it wherever needed.
class Global{
public static int i;
public static String s="";
}
class SomeClass{
public static void main(String args[]){
Global.i=23;
Global.s="Whats up"
}
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Global variables are not possible in java because the
concept of Encapsulation is eliminated here.it is not in
the main() method where we declare variables.
| Is This Answer Correct ? | 5 Yes | 8 No |
What do you mean by flow of struts?
Name container classes in java programming?
What is meant by vector class, dictionary class, hash table class, and property class?
What are the differences between string and stringbuffer?
What is the purpose of the runtime class in java programming?
What is the difference between the ">>" and " >>>" operators in java?
what is jndi?
What is the difference between int and integer in java?
How do you trim a space in java?
How to instantiate static nested classes in java?
What is an example of procedure?
What does it mean to be immutable?