Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Why we can not force Garbage Collection?

7 Answers  


What is abstraction with strong example program? (not a general program)

3 Answers  


Why enumeration is faster than iterator?

0 Answers  


Explain final, finalize() and finally?

11 Answers   Accenture, TCS,


Why is it important to initialize a variable?

0 Answers  






What is the use of an interface?

3 Answers  


When finally clause is executed?

3 Answers  


What is the difference between yielding and sleeping?

0 Answers  


What are other modifiers?

2 Answers   Wipro,


What is the argument type of main() method?

2 Answers  


what r advatages of websphere? & how to deploy?

0 Answers   Saksoft,


If an object is garbage collected, can it become reachable again?

0 Answers  






Categories