0

I know that when we allocate memory using new statement, that memory is allocated on the heap. Say my class looks like this

public class Car{
int prop1;
int prop2;

void method1(){
}

void method2(){}

}

Say in my main method, I have a statement Car c = new Car(); Here variable c is stored in stack memory, while new will allocate memory on heap.

Since prop1, and pro2 are instance variable, they are also stored on the heap, right?

I would like to where are method1, and method2 stored wrt main memory?

Max
  • 9,100
  • 25
  • 72
  • 109

0 Answers0