How do you avoid global variables?



How do you avoid global variables?..

Answer / Poonam Rani Chauhan

Avoid using global variables by minimizing their use, limiting their scope to methods or blocks when necessary, and preferring local variables instead. Encapsulation through classes and private access modifiers can also help limit the visibility of variables.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Name the package that always imported by default?

4 Answers  


what is Vector class?

2 Answers  


how to create multithreaded program? Explain different ways of using thread? : Java thread

1 Answers  


How do you sort a string in alphabetical order in java?

1 Answers  


What is a treemap in java?

1 Answers  


Is null a value?

1 Answers  


Difference between Hash Table and Hash Map?

10 Answers   Persistent,


how to pass the parameters to applets?

1 Answers  


Explain the difference between a Thread and a Process.

1 Answers   Ciena,


What will happen when using pass by reference in java?

1 Answers   HCL,


What is the static keyword?

1 Answers  


Difference between start() and run() method of thread class?

1 Answers  


Categories