• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Stati variables

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just wanted to ask like when the object created all the instance variable and methods are on the heap within the object but what about the class variable where they are created?is it siomething like class also created on the heap with class name to store these class variable
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sweety...

1...class variables also get memory from heap.

2.. class is not created in memory. it's a prototype which binds code and data together , it dosen't have physical aapearence in memory.
it is a means of encapsulation for state and behaviour..
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When we run the application variables and Objects both are stored in seprate memory one is called Heap and another is called Stack. class variable, local variable and method offset is stored in stack and Object is stored at heap.
Ex-
MyClass myclassreference = new MyClass(String name, int age);
This statement create an object of type MyClass and stored it at heap but the reference variable "myclassreference" is stored in stack and it consists meomry address of the created object. suppose if the memory address is 1001 of the object then the value of myclassreference will be 1001. Thats why the reference variable points to the object memory location.

I think it will help you....
reply
    Bookmark Topic Watch Topic
  • New Topic