This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes implementation for static and non-static methods stored in memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "implementation for static and non-static methods stored in memory" Watch "implementation for static and non-static methods stored in memory" New topic
Author

implementation for static and non-static methods stored in memory

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 356
In this program i have created two objects s1 and s2 of class sample. The display function(which is member function of
class sample) has common implementation which is shared by s1 and s2. Where is the implementation for the dispaly function
stored? Where is the implementation for static and non-static methods stored in memory?

class sample
{
void display()
{
System.out.println("hello");
}
}

class MainClass
{
public static void main(String str[])
{
sample s1 = new sample();
sample s2 = new sample();
s1.display();
s2.display();
}
}


SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
methods are stored in the stack. Objects and instance variables are in the heap.


I'm a Hood Ornament
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: implementation for static and non-static methods stored in memory
 
Similar Threads
Doubt in String class
Inheritence
polymorphism question
Strings
Why doesn't the subclass variable hide it?