Explain about global variables in Java?

Answers were Sorted based on User's Feedback



Explain about global variables in Java?..

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

Explain about global variables in Java?..

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

Explain about global variables in Java?..

Answer / niranjanravi

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

Post New Answer

More Core Java Interview Questions

What do bitwise operators do?

0 Answers  


how to fing linkedlist is circular or not?

1 Answers   TCS,


What is encapsulation in java?

0 Answers   IBS, NIIT,


how a marker interface gets its functionality and when we implements a marker interface how it got invoked

3 Answers   Mind Tree,


What is the point of java?

0 Answers  






What is java beans?

0 Answers  


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?

0 Answers  


Which is bigger double or float?

0 Answers  


Need to use public,static keywords in main function?

5 Answers  


What are the types of collections in java?

0 Answers  


How variables are declared?

0 Answers  


What is the difference between the paint() and repaint() methods in java programming?

0 Answers  


Categories