Example Classes
************ Example.java ************
public class Example {
public static void main(String[] args) {
Test test = new Test();
test.hello();
}
}
************** Test.java ************
public class Tets {
public void hello() {
System.out.println("Hi");
}
}
My Understanding: In Example.Main
method, test reference will get stored in Java stack memory and Since new Test()
Object has no state so There won't be any Heap memory allocation.
Doubt: Usually We say that Objects get stored in Heap memory but here we don't have any state fields for Test Object, Then will there be any memory allocation in Heap Memory?