Java Concepts

General Concepts

Java is an object-oriented programming language that includes the following features.
  • Platform Independence - Java applications are compiled into bytecode which is stored in class files and loaded in a JVM. Since applications run in a JVM, they can be run on many different operating systems and devices.
  • Object-Oriented - Java is an object-oriented language that take many of the features of C and C++ and improves upon them.
  • Automatic Garbage Collection - Java automatically allocates and deallocates memory so programs are not burdened with that task.
  • Rich Standard Library - Java includes a vast number of useful objects to perform such tasks as input/output, networking, and date manipulation.

Java Heap Space

Java Heap space is used by java runtime to allocate memory to Objects and JRE classes.
Whenever we create any object, it’s always created in the Heap space.
Garbage Collection runs on the heap memory to free the memory used by objects that doesn’t have any reference. Any object created in the heap space has global access and can be referenced from anywhere of the application.


Java Stack Memory

Java Stack memory is used for execution of a thread. They contain method specific values (local variables) and references to other objects in the heap that are getting referred from the method.
Stack memory is always referenced in LIFO (Last-In-First-Out) order. Whenever a method is invoked, a new block is created in the stack memory for the method to hold local variables and references to other objects in the method.

Stack memory size is very less compared to Heap memory.

No comments:

Post a Comment