Professional Documents
Culture Documents
Q&Ajava Interview
Q&Ajava Interview
*Memory is divided into two parts: Stack memory and heap memory.
*Program is run by JVM and JVM can access stack memory only.
*If ‘static’ keyword is not written in main function, JVM won’t be able to access heap memory hence
program won’t be able to run.
*JVM would be able to access the stack memory from outside only when keyword ‘public’ is written.
*You may need to store any type data in main method and there may be multiple values need to be
stored in that hence we define it as String type of array. We write String because any type of data
can be stored in String and in array we can store multiple values.
* We may need to store more than one value that’s the reason we put Array’s operator[].
*Such variable which has written in any method is called local variable. Variable which has been
written outside of method but inside the class called Global variable.
There are two type of global variable: Static global variable and instance global variable. If Static is
not prefixed with variable then it goes into heap memory which is called instance global variable.
*If jvm need to access data from heap then we would need to link stack memory with heap memory
and we make object for the same.
*If any variable or method is non static then we need to make object to run the program.