Core Java Interview Questions and Answers (2024) - InterviewBit 2
Core Java Interview Questions and Answers (2024) - InterviewBit 2
Stack memory is the portion of memory that was assigned to every individual program. And it was
fixed. On the other hand, Heap memory is the portion that was not allocated to the java program but
it will be available for use by the java program when it is required, mostly during the runtime of the
program.
class Main {
public void printArray(int[] array){
for(int i : array)
System.out.println(i);
}
public static void main(String args[]) {
int[] array = new int[10];
printArray(array);
}
}
For this java program. The stack and heap memory occupied by java is -
https://www.interviewbit.com/java-interview-questions/ 1/2
2/8/24, 6:56 AM Core Java Interview Questions and Answers (2024) - InterviewBit
Start Test
https://www.interviewbit.com/java-interview-questions/ 2/2