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 temp in java?

794


What is the difference between member variables initialization and assignment in a constructor?

949


What does the string method compareto () do?

792


Is null a keyword in java?

765


What is the java virtual machine?

869


If goto and const is reserve words than why it is not work in java?

1781


What does java stand for?

804


What are peerless components?

863


Is .net better than java?

788


Can a class extend 2 classes in java?

807


Which one will take more memory: an int or integer?

1008


Why singleton is not thread safe?

811


What is unicode full form?

772


Why string is a class?

754


Can a vector contain heterogenous objects?

835