Suppose I have created a class named test with a member function name fun() that has three variables a=5,b=6.My questions are 1>When will the memory be allotted for these variables at run time or at compile time??? 2>Suppose i do not create a main method then will the memory be allotted for member function fun() and its variables?? 3>suppose i write a main method and from it i create an object q of test class then when shall the memory be allotted for function fun() and its variables ?? 4>When does java set default values of variables declared in a class that has not been assigned with any value??
off course at running time .. how means explanation is given bellow... see there are two stage while execution . 1 - is converting of the source code into byte code this is called as the compilation and during this no memory allocation takes place . and now 2- is the converting of the byte code to machine level i.e binary code for understanding to jvm purpose . this is called as the running phase during this phase jvm will allocate the memory for the data members .
Thanks for your answer but can you answer my 4> question ??