What is the difference between static and non-static
variables?

Answer Posted / santosh mundhe

Static:1)Memory allocated before creation of object.
2)Gets memory on Global segment.
3)Object can't get copy of static variable, each
object shears static variable from global segment.
4)Static variables are not part ob object.

Non-static:
1)Gets memory on satck segment.
2)Object gets copy of non static variable.
3)Non static variables are part of object.

Is This Answer Correct ?    8 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dynamic array in java?

756


What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?

878


Does collectionutils isempty check for null?

1123


What are keywords give examples?

808


What is public/private protected in java?

792


What are java threads?

852


How do you use equal in java?

740


What is a instance variable?

781


What does a method signature consist of?

727


State one difference between a template class and class template.

849


What does sprintf mean?

729


Can we increase size of array?

771


Explain how to convert any java object into byte array.

758


List out benefits of object oriented programming language?

673


How to display all the prime numbers between 1 and 100

724