I am confused regarding whether memory allocation in java occurs at run time or compile time.
For example:
class Test{
int a;
public Test(){
Compile time no memory allocation happens. Only at load and runtime.
Compile time generates .class files that's it.
Remember you need to have a main class to run the program. When you run your program using Java with classpath to .class file, there will be steps like loading & linking etc.,
Classloaders loads the files to permgen.
When main method invoked, there will be stack created and local variables will be placed there
When runtime encounters new it creates object on heap and allocates required memory there like memory required for Test.