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 bitwise operators do?
how to fing linkedlist is circular or not?
What is encapsulation in java?
how a marker interface gets its functionality and when we implements a marker interface how it got invoked
What is the point of java?
What is java beans?
Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?
Which is bigger double or float?
Need to use public,static keywords in main function?
What are the types of collections in java?
How variables are declared?
What is the difference between the paint() and repaint() methods in java programming?