JAVA, JVM, JDK & JRE

BITBEE (Coding & Design)
19 min readOct 7, 2024

--

Java Interview concepts

Java is a popular, versatile, and widely-used programming language known for its simplicity and robustness.

To get more explore java concepts and Real time Java interview faqs, please 🙏🙏 subscribe 🔔 🔔 bitbee at Youtube to crack your next java interview.

Below some of the key features of the Java language:

1. Object-Oriented

Java follows the object-oriented programming (OOP) paradigm, where everything is treated as an object. Key OOP concepts like inheritance, polymorphism, encapsulation, and abstraction are integral to Java, making it highly modular and reusable.

2. Platform Independence (WORA)

Java is known for its “Write Once, Run Anywhere” (WORA) philosophy. Java programs are compiled into platform-independent bytecode, which can run on any system that has a Java Virtual Machine (JVM). This makes Java portable across different operating systems (Windows, Linux, macOS, etc.).

3. Simple and Easy to Learn

Java has a clear and easy-to-understand syntax that is similar to C and C++. However, Java simplifies many complex features like pointers and memory management, making it easier for developers to learn and use.

4. Secure

  • Java provides several built-in security features, such as runtime checking, secure class loading, and bytecode verification. Java’s security model protects against viruses and tampering by restricting the operations that programs can perform, particularly when running untrusted code (e.g., applets).

5. Robust

Java emphasizes early error checking, strong memory management (via garbage collection), and exception handling. It avoids common issues in other languages, such as memory leaks and pointer-related problems. This robustness makes Java reliable for developing mission-critical applications.

6. Multithreaded

Java has built-in support for multithreading, allowing programs to execute multiple threads concurrently. This is particularly useful for developing high-performance applications like games, web servers, and real-time systems that need to handle multiple tasks simultaneously.

7. Interpreted and Compiled

Java combines both compilation and interpretation. Java source code is first compiled into bytecode (via the javac compiler), which is then interpreted by the JVM at runtime. This dual nature provides the benefits of both compiled (faster execution) and interpreted (platform independence) languages.

8. High Performance

While Java is an interpreted language (with bytecode), the introduction of Just-In-Time (JIT) compilers improves its performance significantly. JIT compiles frequently executed bytecode sequences into native machine code at runtime, optimizing performance close to that of native languages like C++.

9. Distributed

Java provides built-in support for developing distributed applications. It facilitates networking through APIs such as RMI (Remote Method Invocation) and CORBA (Common Object Request Broker Architecture), making it easy to communicate between remote systems.

10. Dynamic

Java is considered dynamic because it can adapt to an evolving environment. Classes are loaded dynamically at runtime, and libraries can be linked as needed. Java’s reflective capabilities allow it to inspect classes, objects, and methods during execution.

11. Memory Management (Garbage Collection)

Java handles memory management through automatic garbage collection, freeing up memory that is no longer needed. This reduces the developer’s burden of manually managing memory and helps prevent memory leaks and other related issues.

12. Extensive Standard Library

Java comes with a vast standard library (java.util, java.io, java.net, etc.) that provides numerous reusable functions for tasks such as data structure manipulation, networking, I/O handling, database connections, and GUI development.

13. Rich API and Ecosystem

In addition to the standard library, Java has a rich ecosystem of third-party libraries, frameworks (e.g., Spring, Hibernate, Apache Struts), and tools for various domains such as web development, data science, cloud computing, and mobile app development.

14. Portable

Java programs are platform-independent at both the source and bytecode levels. The JVM abstracts away the specifics of the underlying hardware and operating system, making Java programs portable across different platforms.

15. Architecture Neutral

Java does not rely on any specific architecture. Java bytecode is designed to be portable and can be executed on any processor that has a compatible JVM, regardless of hardware or OS.

16. Scalable

Java is suitable for small-scale applications as well as large, distributed enterprise-level systems. It scales well, both in terms of performance and maintainability, due to its object-oriented design and support for concurrency.

17. Open Source

Java is open-source and maintained by the Oracle Corporation. The availability of its source code ensures transparency, security, and collaboration within the developer community.

18. Community Support

  • Java has a large and active community, which provides constant updates, fixes, and improvements. Java’s wide adoption ensures a wealth of tutorials, documentation, and support for both beginners and professionals.

19. Support for Multiple Paradigms

Although Java is primarily an object-oriented language, it also supports procedural programming. From Java 8 onwards, it has added support for functional programming features (e.g., lambda expressions, streams), making the language more versatile.

20. Support for Web and Mobile Applications

Java is a key language for web development (with frameworks like Spring) and mobile application development, especially for Android, where it serves as the primary language for app creation.

21. Backward Compatibility

Java places a strong emphasis on maintaining backward compatibility. This means code written in older versions of Java can generally run without modification on newer JVMs, making it easier to update projects over time.

In Java, bytecode is generated during the compilation process when the Java source code (written in .java files) is compiled by the Java compiler (javac). Here's a step-by-step explanation of how this process works:

1. Writing the Java Source Code:

First, you write your Java program in human-readable source code using a .java file. For example, you may have a simple Java class like this:

2. Compilation using javac:

Once you have written the source code, you use the Java compiler (javac) to compile the .java file, the Java compiler (javac) translates the human-readable Java source code into Java bytecode.

3. Generating .class File (Bytecode):

The output of the javac command is a .class file, which contains the bytecode. In this case, the generated file would be HelloWorld.class.

Bytecode is an intermediate, platform-independent representation of your Java code. It is not specific to any particular hardware or operating system. Instead, it is designed to be executed by the Java Virtual Machine (JVM), making Java “Write Once, Run Anywhere.”

4. Bytecode and JVM:

The bytecode generated in the .class file is not directly understandable by the underlying operating system or hardware.

Instead, the JVM reads and interprets the bytecode and converts it into machine code that can be executed by the host system’s CPU.

This bytecode ensures platform independence, meaning the same .class file can run on any machine that has a compatible JVM (whether it’s Windows, Linux, macOS, or others).

Key Aspects of Bytecode Generation:

  • Platform Independence: Bytecode is the key to Java’s “Write Once, Run Anywhere” philosophy. The same bytecode can be executed on any platform that has a JVM.
  • Optimization: The Java compiler optimizes your source code while converting it to bytecode to improve runtime performance.
  • Intermediate Language: Bytecode serves as an intermediate language that balances portability and performance. Unlike source code, bytecode is not intended for human readability but for machine efficiency.

Summary of the Bytecode Generation Process:

  1. Source Code (.java file) → Written by the developer.
  2. Compilation → The javac compiler translates source code into bytecode.
  3. Bytecode (.class file) → Platform-independent code that is ready to be executed by the JVM.
  4. Execution → The JVM interprets or compiles the bytecode into machine code for execution on the host system.

In short, the Java compiler (javac) is responsible for generating the bytecode by translating your Java source code into an intermediate form, which can be executed by the JVM on any platform.

The Java Virtual Machine (JVM) is a key component of the Java programming language, responsible for running Java bytecode and providing platform independence. It acts as an abstract computing machine that enables Java programs to be executed on any device or operating system that has a compatible JVM installed, regardless of the underlying hardware or platform. Here’s a detailed explanation of what the JVM is and its role:

Key Responsibilities of the JVM:

  1. Platform Independence:

The JVM allows Java to follow the “Write Once, Run Anywhere” (WORA) philosophy. Java code is compiled into bytecode, a platform-independent code. The JVM interprets this bytecode and converts it into native machine code that can be understood by the host operating system.

2. Execution of Java Bytecode:

Java source code is first compiled into bytecode using the Java compiler (javac). This bytecode is not directly executed by the underlying machine. Instead, the JVM interprets or compiles this bytecode at runtime into machine code specific to the platform, allowing Java programs to run on different systems.

3. Memory Management (Garbage Collection):

The JVM manages memory automatically using Garbage Collection. It tracks objects created by the program and automatically frees up memory by removing objects that are no longer needed, preventing memory leaks and optimizing performance.

4. Class Loading:

The JVM dynamically loads classes during program execution as needed. This allows for more efficient memory usage and supports features like reflection and dynamic method invocation.

5. Security:

  • The JVM enforces security mechanisms to prevent malicious code execution, especially in networked or distributed environments (such as applets and web-based Java applications). It ensures that untrusted code cannot access sensitive system resources without appropriate permissions.

6. Exception Handling:

JVM provides built-in support for exception handling, allowing developers to write more robust programs that can handle runtime errors effectively. The JVM catches exceptions thrown during program execution and provides mechanisms to recover from errors.

JVM Architecture:

image copyright BITBEE (Coding & Design)

The Java Virtual Machine (JVM) is a critical component of the Java platform that executes Java bytecode and provides an environment for Java applications. The JVM has several key components, each with specific functions necessary for executing a Java program efficiently. Below are the main components of the JVM and their respective roles:

1. Class Loader Subsystem

  • Function: The Class Loader is responsible for loading class files (Java bytecode) into the JVM at runtime. It reads .class files, verifies them, and loads them into memory to prepare them for execution.
  • Sub-components:
  • Loading: Loads .class files from various sources like file systems, network, or custom sources.
  • Linking: Performs three steps: verification (checks the correctness of the loaded classes), preparation (allocates memory for class variables), and resolution (resolves symbolic references to actual memory addresses).
  • Initialization: Invokes the class constructor (<clinit>()) and initializes static variables.

Key Points:

  • Classes are loaded dynamically at runtime.
  • JVM uses different class loaders (Bootstrap, Extension, and Application class loaders).

2. Runtime Data Areas

The JVM organizes its memory into different runtime areas for executing Java programs. These areas are allocated when a program is executed and deallocated when the program terminates.

a. Method Area

  • Function: Stores class-level data, including information about class structures (e.g., runtime constant pool, method data, field data, method code).

Key Points:

  • Stores static variables, constants, and method code.
  • Shared among all threads.

b. Heap

  • Function: Stores all objects and arrays created by the program. The heap is the runtime data area from which memory is allocated for Java objects.

Key Points:

  • It is shared among all threads.
  • Garbage collection occurs in the heap to reclaim memory used by objects that are no longer reachable.

c. Stack

  • Function: Each thread has its own Java stack. It stores frames for method invocations, which contain local variables, partial results, and method calls.
  • Key Points:
  • Each method call creates a new stack frame.
  • The stack is thread-specific, meaning each thread has its own stack for storing execution data.

d. Program Counter (PC) Register

  • Function: Each thread has its own PC register, which keeps track of the address of the currently executing Java bytecode instruction.
  • Key Points:
  • Stores the address of the instruction currently being executed by the thread.
  • If a native method is being executed, the PC register is undefined.

e. Native Method Stack

  • Function: This is used for executing native (non-Java) methods. Native methods are written in languages like C or C++ and interfaced with Java using the Java Native Interface (JNI).
  • Key Points:
  • Contains the data required to invoke native methods.
  • The stack stores frames similar to the Java stack, but for native method calls.

3. Execution Engine

The execution engine is responsible for executing the bytecode loaded into the JVM. It reads and interprets the bytecode and converts it into machine code that can be executed by the underlying system.

a. Interpreter

  • Function: The interpreter reads the bytecode instructions and interprets them one at a time, converting them into machine instructions and executing them.

Key Points:

  • Simple and less efficient compared to the JIT compiler.
  • Slower execution as it interprets bytecode line by line.

b. Just-In-Time (JIT) Compiler

  • Function: To improve performance, the JIT compiler compiles bytecode into native machine code at runtime. Frequently executed bytecode sequences are compiled into machine code to reduce the overhead of interpretation.

Key Points:

  • Increases execution speed by compiling hot spots (frequently executed code).
  • After JIT compilation, the machine code is executed directly instead of interpreting bytecode.

c. Garbage Collector

  • Function: The garbage collector automatically manages memory by reclaiming memory occupied by objects that are no longer reachable from the program. This prevents memory leaks.

Key Points:

  • Uses algorithms like mark-and-sweep or generational garbage collection.
  • Operates in the background to reclaim memory and optimize heap usage.

4. Native Method Interface (JNI — Java Native Interface)

  • Function: Provides an interface to call or access functions written in languages like C, C++, or assembly from within Java code.

Key Points:

  • Allows Java programs to use platform-specific native libraries or legacy code.
  • Useful for performance-critical operations or using existing system libraries.

5. Native Method Libraries

  • Function: These are libraries written in native languages that are accessed via the Java Native Interface. They contain platform-specific code and are often used for low-level tasks such as I/O, graphics, or device interaction.

Key Points:

  • Typically system libraries like .dll files on Windows or .so files on Linux/Unix systems.
  • Loaded into the JVM at runtime when native methods are invoked.

JVM Execution Flow:

  1. Class Loading: The class loader loads the required .class files.
  2. Memory Allocation: JVM allocates memory in the runtime data areas (method area, heap, stack).
  3. Bytecode Execution: The interpreter or JIT compiler executes the bytecode.
  4. Garbage Collection: JVM periodically performs garbage collection to free up memory.
  5. Native Method Calls: JNI allows Java programs to call methods written in native code.

Summary:

The JVM consists of several critical components — Class Loader, Runtime Data Areas (Heap, Stack, etc.), Execution Engine (Interpreter, JIT, Garbage Collector), and JNI — which together handle loading, executing, and managing memory for Java applications. This architecture enables Java to be platform-independent, efficient, and secure.

Interpreter vs JIT Compiler

The Interpreter and the Just-In-Time (JIT) Compiler are two critical components of the Java Virtual Machine (JVM) responsible for executing Java bytecode. They both convert Java bytecode into machine code, but they operate differently, leading to different performance characteristics.

1. Interpreter

The Interpreter reads and executes Java bytecode instructions one at a time. It translates bytecode into machine code on the fly, but does so line by line. This approach is simple and has a lower startup time but tends to be slower in the long run because it has to interpret the bytecode every time a method is invoked.

Key Characteristics of the Interpreter:

  • Execution Speed: Slower because each bytecode instruction must be interpreted repeatedly every time it is executed.
  • Low Overhead: It starts executing the program immediately, making it ideal for quick execution of small programs or less frequently executed code.
  • Used for Cold Code: The interpreter is mainly used for cold code (code that is executed infrequently or only once).
  • No Optimization: The interpreter does not optimize bytecode execution. Every time a method or instruction is called, it is interpreted again.

Pros:

  • Fast Startup Time: The interpreter begins executing the code immediately without needing to compile it first.
  • Simpler Design: It interprets bytecode directly without the complexity of optimizing or compiling.

Cons:

  • Slower Performance: Repeated interpretation of bytecode instructions leads to slower execution for long-running or frequently executed code.

2. JIT (Just-In-Time) Compiler

The Just-In-Time (JIT) Compiler works in conjunction with the interpreter but takes a different approach. Instead of interpreting bytecode instruction by instruction, the JIT compiler compiles frequently executed code (hot spots) into native machine code at runtime. Once compiled, the machine code can be executed directly by the CPU, improving the performance significantly.

Key Characteristics of the JIT Compiler:

  • Execution Speed: Faster after compilation because the bytecode is converted into native machine code, which can be directly executed by the CPU.
  • High Overhead at Start: There’s an initial delay for compilation when the code is first encountered, but once compiled, the code runs much faster.
  • Used for Hot Code: The JIT compiler is applied to hot code (code that is executed frequently). JVM profiles the code at runtime and identifies the hot spots to compile.
  • Optimization: The JIT compiler performs optimizations like inlining, loop unrolling, and method caching, which improve performance further.

Pros:

  • Improved Performance: Native machine code execution is much faster than interpreted bytecode, making JIT very efficient for long-running or frequently executed code.
  • Optimization: JIT applies optimizations that lead to more efficient machine code, improving performance even further.

Cons:

  • Compilation Overhead: JIT compilation takes time, leading to a performance overhead during the first few executions of the code (also known as warm-up time).
  • Memory Overhead: Compiled machine code is stored in memory, increasing the memory footprint compared to interpretation.

How They Work Together in the JVM:

  • When a Java program is executed, the JVM initially uses the interpreter to quickly start running the bytecode. For code that is executed frequently, the JVM switches to the JIT compiler to compile that code into native machine code for better performance.
  • This combined approach allows for fast startup times (via the interpreter) and high execution performance for hot code (via JIT compilation).

Example of Usage:

  • Suppose you have a method that gets called 10,000 times during the execution of a program. Initially, the interpreter will interpret the method’s bytecode. After detecting that the method is executed frequently (based on profiling data), the JVM will use the JIT compiler to compile the method into machine code. For all subsequent calls, the JVM will execute the compiled machine code, resulting in significantly faster performance.

Summary:

  • Interpreter: Best suited for quickly starting the execution of code and for code that is not executed frequently. It interprets each instruction at runtime, which is simpler but slower for long-running applications.
  • JIT Compiler: Used for frequently executed code, providing high performance by compiling bytecode into native machine code at runtime. While it incurs an initial compilation overhead, it significantly speeds up the execution of hot code through optimization techniques.

Both the interpreter and the JIT compiler are essential for the efficient execution of Java programs, providing a balance between fast startup times and long-term performance optimization.

Javac is not part of JVM then?

Correct! javac is not part of the JVM (Java Virtual Machine). Instead, javac is the Java compiler, and it is part of the Java Development Kit (JDK). The JDK is a complete software development environment used for developing Java applications, while the JVM is specifically for running Java programs.

Here’s a breakdown of how javac and the JVM are related but distinct:

1. javac (Java Compiler)

  • Part of the JDK: The Java compiler (javac) is part of the JDK, not the JVM. The JDK is used to develop and compile Java code.
  • Role: javac compiles Java source code (written in .java files) into bytecode (stored in .class files). This bytecode is platform-independent and can be executed on any system that has a compatible JVM.
  • Source code: .java files (human-readable Java code)
  • Compiled output: .class files (bytecode)
  • Output: The output of javac is the bytecode, which is not tied to any specific platform or operating system.

2. JVM (Java Virtual Machine)

  • Part of the JRE: The JVM is part of the Java Runtime Environment (JRE), which is responsible for executing Java bytecode.
  • Role: The JVM takes the compiled bytecode (from the .class files generated by javac) and executes it. It converts bytecode into machine code specific to the host system (via interpretation or JIT compilation), allowing Java programs to run on different platforms.
  • Execution: The JVM is platform-dependent (there are different JVMs for different platforms), but the bytecode it runs is platform-independent.

How javac and JVM Work Together:

  1. Development:
  • A developer writes Java code in .java files.

2. Compilation (javac):

  • The javac compiler converts the .java files into platform-independent bytecode stored in .class files.

3. Execution (JVM):

  • The JVM loads the bytecode from the .class files, interprets or compiles it into machine code (depending on the JVM implementation), and executes it on the specific platform.

what are different kind of class loaders and what they do?

In Java, ClassLoaders are responsible for dynamically loading Java classes into the JVM during runtime. Java’s class-loading mechanism is hierarchical, and it follows a delegation model. There are several types of ClassLoaders, each with specific roles and responsibilities.

Here’s a detailed breakdown of the different kinds of ClassLoaders and what they do:

1. Bootstrap ClassLoader (Primordial ClassLoader)

What it does:

  • The Bootstrap ClassLoader is the parent of all class loaders and is part of the core JVM. It loads the essential Java classes, such as those from the java.lang package (e.g., Object, String, Thread) and core runtime libraries.
  • It loads classes from the Java Runtime Environment (JRE), typically from the rt.jar file in the JDK/JRE installation directory.
  • Implemented in: Native code (written in C/C++).
  • Visibility: It’s not accessible directly to the user and does not have a ClassLoader object reference.

2. Extension (Platform) ClassLoader

What it does:

  • The Extension ClassLoader (or Platform ClassLoader, starting from JDK 9) is responsible for loading classes from the extensions of the standard Java platform. These extensions are additional libraries that provide extended functionality to the core Java libraries.
  • It loads classes from the lib/ext directory or from the java.ext.dirs system property.
  • Parent: Bootstrap ClassLoader.
  • Visible: Yes, it can be referenced through ClassLoader.getParent().

Example: Loads classes from external libraries or extended packages such as security classes like javax.crypto.* or javax.net.ssl.*.

3. Application (System) ClassLoader

What it does:

  • The Application ClassLoader is responsible for loading classes from the application’s classpath. It loads user-defined classes from directories or JAR files specified in the CLASSPATH environment variable or command-line arguments.
  • It is the default class loader for user-defined classes in Java applications.
  • Parent: Extension ClassLoader.
  • Visible: Yes, it can be accessed programmatically through ClassLoader.getSystemClassLoader().

Example: Loads the classes of your Java application, such as com.myapp.MyClass.

4. Custom (User-Defined) ClassLoader

What it does:

  • Java allows developers to define their own Custom ClassLoaders by extending the ClassLoader class and overriding its methods, such as findClass() or loadClass().
  • Custom class loaders are useful for loading classes in a specialized way, such as from a network, database, or encrypted JAR files. This allows applications to define their own class-loading behavior beyond the standard mechanisms.
  • Parent: Usually, the Application ClassLoader or another class loader specified by the developer.
  • Visible: Yes, these are explicitly created and managed by the developer.

Example: A class loader that loads classes from a remote server over the network.

Delegation Model in Class Loading

The Java class loader hierarchy follows a parent-first delegation model. This means that when a class needs to be loaded, the class loader:

  1. Delegates the class-loading request to its parent first.
  2. If the parent class loader cannot load the class (i.e., the class is not found in its classpath), the request passes down to the

JDK (Java Development Kit) and JRE (Java Runtime Environment) are both key components of the Java platform, but they serve different purposes in the Java development and execution process. Here’s a detailed comparison of JDK vs. JRE:

1. JDK (Java Development Kit)

What is JDK?

  • The JDK is a software development environment used to develop Java applications and applets.
  • It contains the tools and libraries required for Java development, including the Java compiler (javac), Java Virtual Machine (JVM), debuggers, documentation tools, and other utilities.
  • The JDK includes the JRE as part of its package, so you can both develop and run Java programs using the JDK.

Components of JDK:

  • JRE: The JDK includes the JRE, which is necessary for running Java applications.
  • javac (Java Compiler): Compiles Java source code into bytecode (.class files).
  • Java Debugger (jdb): Used for debugging Java applications.
  • JavaDoc: A tool for generating API documentation in HTML format from Java source code comments.
  • Other Development Tools: Includes other tools like jconsole, javap, jar (for packaging), etc.

Who Uses JDK?

  • Java Developers: Anyone who writes, compiles, and debugs Java applications needs the JDK.

Use Case:

  • Development: Writing and compiling Java programs.
  • Tools for Development: If you’re building or maintaining Java applications, the JDK provides all the tools you need.

2. JRE (Java Runtime Environment)

What is JRE?

  • The JRE is the environment used to run Java programs.
  • It includes the JVM (Java Virtual Machine), core libraries, and other necessary components required to execute Java bytecode.
  • The JRE does not contain development tools like the compiler (javac) or debugger. It is designed only for running already compiled Java applications.

Components of JRE:

  • JVM (Java Virtual Machine): Executes Java bytecode and translates it into machine code specific to the operating system.
  • Core Java Libraries: Includes essential libraries (such as java.lang, java.util, etc.) required to run Java programs.
  • Other Runtime Components: Garbage collector, class loader, etc., for memory management and loading classes at runtime.

Who Uses JRE?

  • End Users: Users who only want to run Java applications (not develop them) need the JRE.
  • Application Servers: If you are deploying Java applications, the JRE provides the runtime environment to execute them.

Use Case:

  • Execution: Running Java programs that have already been compiled (i.e., .class files).
  • Runtime Only: It’s intended for environments where Java programs need to be executed, but no development (compilation) is required.

Key Differences Between JDK and JRE

AspectJDK (Java Development Kit)JRE (Java Runtime Environment)PurposeTo develop and run Java programs.To run Java programs (runtime only).IncludesIncludes JRE, JVM, and development tools (e.g., javac, jdb, jar, etc.).Includes only JVM, core libraries, and components to run Java applications.Who Uses ItJava developers (who write, compile, and debug Java code).End users who want to run Java programs.Main Toolsjavac, jdb, javap, JavaDoc, jar, etc.JVM and Java class libraries for execution.CompilationCan compile Java source code to bytecode (.class files).Cannot compile; only executes precompiled bytecode.Development ToolsProvides development tools for writing and debugging Java applications.Does not include development tools.Memory FootprintLarger, because it contains both JRE and development tools.Smaller, as it only contains the runtime environment.PackageIncludes JRE.Standalone; no development tools are included.

Here are some frequently asked Java interview questions based on the topics we’ve covered so far (JVM, JDK vs JRE, ClassLoaders, and others):

Here’s a list of frequently asked Java interview questions based on the topics we’ve discussed:

JVM (Java Virtual Machine)

  1. What is the JVM, and what is its role in Java?
  2. What are the main components of the JVM?
  3. What is the difference between JVM, JRE, and JDK?
  4. How does the JVM execute bytecode?
  5. What is Just-In-Time (JIT) compilation, and how does it differ from interpretation?
  6. What is garbage collection in the JVM, and how does it work?

JDK vs JRE

  1. What is the difference between JDK and JRE?
  2. Why do we need both JDK and JRE?
  3. Can you run Java programs without the JDK?

ClassLoaders

  1. What is a ClassLoader in Java?
  2. What are the different types of ClassLoaders in Java?
  3. How does the delegation model of ClassLoaders work?
  4. What is the role of the Bootstrap ClassLoader?
  5. How can you create a custom ClassLoader in Java?
  6. How does the Application (System) ClassLoader differ from the Extension ClassLoader?

Java Compilation & Execution Process

  1. How is bytecode generated in Java?
  2. What happens when you compile a Java program?
  3. What is the role of the javac compiler?

Interpreter vs JIT Compiler

  1. What is the difference between the interpreter and the JIT compiler?
  2. What are the advantages of using JIT compilation in Java?

These questions cover core concepts related to Java’s runtime environment, development tools, and class loading mechanism.

I hope this story helped you to understand the basics of java features, JVM, JDK & JRE with must know interview FAQs.

Please drop some claps and don’t forgrt to subscribe bitbee at Youtube

--

--

BITBEE (Coding & Design)

Software Er | #Tech #Coding #interviews #bitbee #datastructures #algorithms #leetcode