If your team member writes code with lots of static
variables and static methods, will it cause any side effects?
Answers were Sorted based on User's Feedback
Answer / abhinav
If the code is small, then there wont be any significant
problems, but if the program is huge, then it can severly
hamper the program performance. use of static
variables/methods are one of the biggest reasons for memory
leaks
Is This Answer Correct ? | 6 Yes | 2 No |
Yes!!! We can define the several static method and variable
and those are vary easy to access by Class Name or by class
instance.
But Only problem with static method and variable is that
there is Maximum chance of data corruption. bcz of static
method and variable are accessed by diff-2 thread at the
same time. Mean at the same time one or more then one thread
can change the value of static variable.
So conclusion is this if we can define more static variable
and method so and our program have hug line of code at that
time programs output may be inconsistent.
Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between == and === javascript?
Explain all java features with real time examples
Why map is used in java?
what is object slice?
What exceptions occur during serialization?
In what types of operations an ArithmeticException will be thrown?
Which are different kinds of source code?
Why would you desing a J2EE application so user data is entered by way of a JSP page and managed by an underlying Java Beans class?
Why do we declare a class static?
Write a program to show whether a graph is a tree or not using adjacency matrix.
11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B”); } 16. } 17. public static void main(String[] args) { 18. new B().process(); 19. } What is the result? 1 B 2 The code runs with no output. 3 Compilation fails because of an error in line 12. 4 Compilation fails because of an error in line 15.
What are reference variables in java?