Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT Notes in Hindi & English : JVM आंतरिक संरचना: क्लासलोडर, बाइटकोड (.class) और JIT कंपाइलर और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT (JVM आंतरिक संरचना: क्लासलोडर, बाइटकोड (.class) और JIT कंपाइलर) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।

Overview: The Java Virtual Machine (JVM) is an abstract stack-based computing machine that loads, verifies, and executes compiled .class bytecode files to achieve Java's platform independence. It coordinates three core subsystems—the ClassLoader, Runtime Data Areas, and an Execution Engine powered by an Interpreter and a Just-In-Time (JIT) compiler—for high-throughput native performance.

अध्याय सार: जावा वर्चुअल मशीन (JVM) एक एब्स्ट्रैक्ट स्टैक-आधारित कंप्यूटिंग मशीन है जो जावा को प्लेटफॉर्म-स्वतंत्र बनाने के लिए संकलित .class बाइटकोड फ़ाइलों को लोड, सत्यापित और निष्पादित करती है। यह उच्च गति के नेटिव प्रदर्शन के लिए तीन मुख्य उप-प्रणालियों—ClassLoader, Runtime Data Areas, तथा Interpreter और Just-In-Time (JIT) कंपाइलर से युक्त Execution Engine—का समन्वय करती है।

Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT: Detailed Notes & Architecture (JVM आंतरिक संरचना: क्लासलोडर, बाइटकोड (.class) और JIT कंपाइलर)

1. ClassLoader Subsystem and Parent Delegation Model (ClassLoader उप-प्रणाली और पेरेंट डेलिगेशन मॉडल)

[EN] The ClassLoader subsystem dynamically brings .class bytecode into JVM memory through three sequential phases: Loading, Linking, and Initialization. During Loading, the Bootstrap ClassLoader (written in native C/C++) loads core JDK modules such as java.lang, followed by the Platform ClassLoader and Application ClassLoader under the Parent Delegation Model to prevent class spoofing. Linking consists of Verification (checking bytecode format and 0xCAFEBABE magic number), Preparation (allocating static variables with zero/default values), and Resolution (replacing symbolic references with direct memory pointers in the Runtime Constant Pool). Finally, Initialization assigns programmer-specified static values and executes static initializer blocks via the <clinit> method.

[HI] ClassLoader उप-प्रणाली .class बाइटकोड को तीन क्रमिक चरणों—Loading, Linking और Initialization—के माध्यम से डायनामिक रूप से JVM मेमोरी में लाती है। Loading के दौरान Bootstrap ClassLoader (नेटिव C/C++ में लिखा) java.lang जैसे कोर JDK पैकेज लोड करता है, जिसके बाद क्लास स्पूफिंग रोकने हेतु Parent Delegation Model के तहत Platform और Application ClassLoader काम करते हैं। Linking में Verification (बाइटकोड नियम और 0xCAFEBABE मैजिक नंबर की जांच), Preparation (स्टैटिक वेरिएबल्स को डिफ़ॉल्ट मान आवंटित करना) और Resolution (प्रतीकात्मक संदर्भों को डायरेक्ट मेमोरी रेफरेंस में बदलना) शामिल हैं। अंत में Initialization चरण में स्टैटिक वेरिएबल्स को वास्तविक मान मिलते हैं और <clinit> द्वारा static ब्लॉक्स निष्पादित होते हैं।

2. Bytecode Structure and Platform Independence (बाइटकोड संरचना और प्लेटफॉर्म स्वतंत्रता)

[EN] When javac compiles a .java source file, it produces architecture-neutral .class bytecode rather than CPU-specific machine instructions. Every valid Java class file begins with the 4-byte magic number 0xCAFEBABE followed by minor/major class file version numbers and the constant pool table. JVM instructions use 1-byte opcodes (allowing up to 256 distinct opcodes, around 200 actively defined) operating on a per-frame operand stack rather than hardware registers. Because each operating system provides its own JVM binary implementing the same JVM Specification, identical .class bytecode runs unaltered across Windows, Linux, and macOS.

[HI] जब javac कंपाइलर किसी .java सोर्स फ़ाइल को कंपाइल करता है, तो वह CPU-विशिष्ट मशीन कोड के बजाय प्लेटफॉर्म-तटस्थ .class बाइटकोड उत्पन्न करता है। प्रत्येक वैध जावा क्लास फ़ाइल 4-बाइट मैजिक नंबर 0xCAFEBABE से शुरू होती है, जिसके बाद मेजर/माइनर वर्जन नंबर और कांस्टेंट पूल टेबल आती है। JVM निर्देश हार्डवेयर रजिस्टरों के बजाय प्रति-फ़्रेम ऑपरेंड स्टैक पर कार्य करने वाले 1-बाइट ऑपकोड्स (अधिकतम 256 संभावित, लगभग 200 उपयोग में) का उपयोग करते हैं। चूंकि प्रत्येक ऑपरेटिंग सिस्टम समान JVM विनिर्देश का पालन करने वाला अपना JVM बाइनरी प्रदान करता है, इसलिए एक ही .class फ़ाइल Windows, Linux और macOS पर बिना बदलाव के चलती है।

3. JVM Runtime Data Areas (JVM रनटाइम डेटा क्षेत्र)

[EN] JVM partitions memory into thread-shared and thread-private Runtime Data Areas while executing bytecode. The Method Area (implemented as native-memory Metaspace since Java 8, replacing PermGen) and the Heap (storing all class instances and arrays, managed by Garbage Collection) are shared across all threads. Each thread maintains its own private JVM Stack (storing stack frames with local variables and operand stacks), a Program Counter (PC) Register holding the address of the current bytecode instruction (undefined for native methods), and a Native Method Stack. Insufficient space in the Heap triggers OutOfMemoryError, whereas deep recursion exhausting a thread's JVM Stack triggers StackOverflowError.

[HI] बाइटकोड निष्पादन के दौरान JVM मेमोरी को थ्रेड-साझा (thread-shared) और थ्रेड-निजी (thread-private) रनटाइम डेटा क्षेत्रों में विभाजित करता है। Method Area (Java 8 से PermGen के स्थान पर नेटिव मेमोरी में Metaspace) और Heap (जहाँ सभी ऑब्जेक्ट और एरे संग्रहीत होते हैं और Garbage Collector द्वारा प्रबंधित होते हैं) सभी थ्रेड्स के बीच साझा होते हैं। प्रत्येक थ्रेड का अपना निजी JVM Stack (स्थानीय वेरिएबल्स और ऑपरेंड स्टैक वाले स्टैक फ़्रेम), Program Counter (PC) Register (वर्तमान निर्देश का पता, जो native मेथड्स के लिए अपरिभाषित रहता है), और Native Method Stack होता है। Heap भरने पर OutOfMemoryError आता है, जबकि गहरे रिकर्शन से JVM Stack भरने पर StackOverflowError उत्पन्न होता है।

4. Execution Engine: Interpreter, JIT Compiler, and GC (एग्जीक्यूशन इंजन: इंटरप्रेटर, JIT कंपाइलर और GC)

[EN] The Execution Engine converts verified bytecode into executable machine operations using both an Interpreter and a Just-In-Time (JIT) compiler. The Interpreter reads and executes bytecode instructions sequentially for fast startup, but re-interpreting frequently executed loops incurs runtime overhead. To solve this, the HotSpot JIT profiler monitors method invocation and loop back-edge counters; once a threshold is crossed, the JIT compiles those 'hotspots' into optimized native machine code cached in the Code Cache. Modern HotSpot JVM uses Tiered Compilation (C1 client compiler for quick optimization and C2 server compiler for aggressive optimizations like method inlining, dead-code elimination, and escape analysis) alongside automatic Garbage Collection.

[HI] Execution Engine सत्यापित बाइटकोड को चलाने के लिए Interpreter और Just-In-Time (JIT) कंपाइलर दोनों का संयोजन उपयोग करता है। Interpreter तेज स्टार्टअप के लिए बाइटकोड निर्देशों को पंक्ति-दर-पंक्ति निष्पादित करता है, परंतु बार-बार चलने वाले लूप्स को हर बार इंटरप्रेट करने से गति धीमी होती है। इसे हल करने हेतु HotSpot JIT प्रोफाइलर मेथड कॉल और लूप बैक-एज काउंटर्स की निगरानी करता है और सीमा पार होने पर उन 'हॉटस्पॉट्स' को Code Cache में संग्रहीत अनुकूलित नेटिव मशीन कोड में कंपाइल कर देता है। आधुनिक HotSpot JVM स्वचालित Garbage Collection के साथ Tiered Compilation (त्वरित अनुकूलन के लिए C1 और मेथड इनलाइनिंग व एस्केप एनालिसिस जैसे गहन अनुकूलन के लिए C2 कंपाइलर) का उपयोग करता है।

Syntax, Formula & Technical Example (Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT)

public class JvmLoaderDemo {
    static int counter = 42; // Initialized in Linking->Preparation as 0, then 42
    public static void main(String[] args) {
        ClassLoader appLoader = JvmLoaderDemo.class.getClassLoader();
        System.out.println("Application Loader: " + appLoader);
        System.out.println("Platform Loader: " + appLoader.getParent());
        System.out.println("Bootstrap Loader: " + appLoader.getParent().getParent()); // prints null
        System.out.println("String Loader: " + String.class.getClassLoader());       // prints null
    }
}

Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT Quick Reference & Comparison Table

JVM Subsystem / ComponentPrimary ResponsibilityKey Exam Fact
Bootstrap ClassLoaderLoads core JDK classes like java.lang.StringWritten in native C/C++; getClassLoader() returns null
Bytecode VerifierValidates stack discipline, type safety, and formatChecks 4-byte 0xCAFEBABE magic header during Linking
JIT CompilerCompiles frequently executed hotspot methods to native codeUses C1/C2 tiered compilation, inlining, and escape analysis
JVM Heap AreaStores all runtime objects and arrays across threadsManaged by Garbage Collector; overflow throws OutOfMemoryError

Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT Top 20 Bilingual MCQs with Answers

Q1. Which 4-byte hexadecimal magic number identifies every valid compiled Java .class file?

(कौन सा 4-बाइट हेक्साडेसिमल मैजिक नंबर प्रत्येक वैध संकलित जावा .class फ़ाइल की पहचान करता है?)

(A) 0xCAFEBABE

(B) 0xFEEDFACE

(C) 0xDEADBEEF

(D) 0xBAADF00D

Correct Answer: (A)

[EN] Every valid Java class file starts with the 4-byte header 0xCAFEBABE checked during ClassLoader Linking Verification.

[HI] प्रत्येक वैध जावा क्लास फ़ाइल 4-बाइट हेडर 0xCAFEBABE से शुरू होती है जिसे ClassLoader लिंकिंग के Verification चरण में जांचा जाता है।

Q2. What does String.class.getClassLoader() return in standard HotSpot JVM?

(मानक HotSpot JVM में String.class.getClassLoader() क्या लौटाता है?)

(A) sun.misc.Launcher$AppClassLoader

(B) java.lang.BootstrapLoader

(C) null

(D) jdk.internal.loader.PlatformClassLoader

Correct Answer: (C)

[EN] java.lang.String is loaded by the native Bootstrap ClassLoader, which has no Java object representation and therefore returns null.

[HI] java.lang.String को नेटिव Bootstrap ClassLoader लोड करता है, जिसका कोई जावा ऑब्जेक्ट प्रतिनिधित्व नहीं होने के कारण यह null लौटाता है।

Q3. In which phase of the ClassLoader lifecycle are static variables allocated memory and assigned default zero values before explicit initialization?

(ClassLoader जीवनचक्र के किस चरण में स्टैटिक वेरिएबल्स को मेमोरी आवंटित करके स्पष्ट इनिशियलाइज़ेशन से पहले डिफ़ॉल्ट शून्य मान दिए जाते हैं?)

(A) Linking - Resolution

(B) Linking - Preparation

(C) Initialization

(D) Loading

Correct Answer: (B)

[EN] During Linking's Preparation phase, static fields receive memory in the Method Area and default values (0, false, null); explicit values are assigned later in Initialization.

[HI] Linking के Preparation चरण में स्टैटिक फ़ील्ड्स को मेमोरी और डिफ़ॉल्ट मान (0, false, null) मिलते हैं; स्पष्ट मान बाद में Initialization में दिए जाते हैं।

Q4. In Java 8 and later HotSpot JVMs, which memory space replaced PermGen for storing class metadata?

(Java 8 और उसके बाद के HotSpot JVM में क्लास मेटाडेटा संग्रहीत करने के लिए किस मेमोरी स्पेस ने PermGen का स्थान लिया?)

(A) Eden Space

(B) Metaspace

(C) Code Cache

(D) Survivor Space

Correct Answer: (B)

[EN] Java 8 removed Permanent Generation (PermGen) from the JVM heap and replaced it with Metaspace allocated in native OS memory.

[HI] Java 8 ने JVM हीप से PermGen को हटाकर उसके स्थान पर नेटिव OS मेमोरी में आवंटित Metaspace को लागू किया।

Q5. Which JVM Runtime Data Area is shared among all active threads rather than being private to a single thread?

(कौन सा JVM रनटाइम डेटा क्षेत्र किसी एक थ्रेड तक सीमित रहने के बजाय सभी सक्रिय थ्रेड्स के बीच साझा होता है?)

(A) Heap Area

(B) JVM Stack

(C) Program Counter (PC) Register

(D) Native Method Stack

Correct Answer: (A)

[EN] Heap and Method Area are shared across all threads, whereas PC Register, JVM Stack, and Native Method Stack are created per thread.

[HI] Heap और Method Area सभी थ्रेड्स में साझा होते हैं, जबकि PC Register, JVM Stack और Native Method Stack प्रत्येक थ्रेड के लिए अलग बनते हैं।

Q6. What is the primary architectural purpose of the Just-In-Time (JIT) compiler inside the JVM Execution Engine?

(JVM Execution Engine के भीतर Just-In-Time (JIT) कंपाइलर का मुख्य वास्तुकला उद्देश्य क्या है?)

(A) Managing thread scheduling in the OS kernel

(B) Compiling frequently executed bytecode hotspots into native machine code at runtime

(C) Translating Java source code directly into .class files

(D) Assigning static variables during class linking

Correct Answer: (B)

[EN] The JIT compiler eliminates repeated interpretation overhead by compiling hot methods and loops into native CPU machine code cached in memory.

[HI] JIT कंपाइलर बार-बार चलने वाले हॉट मेथड्स और लूप्स को नेटिव CPU मशीन कोड में संकलित करके इंटरप्रिटेशन ओवरहेड को समाप्त करता है।

Q7. Under the Parent Delegation Model, which ClassLoader is consulted first when a user-defined class needs to be loaded?

(Parent Delegation Model के तहत जब किसी यूज़र-डिफ़ाइंड क्लास को लोड करना होता है, तो सबसे पहले किस ClassLoader से अनुरोध किया जाता है?)

(A) Platform ClassLoader

(B) Bootstrap ClassLoader

(C) Custom URLClassLoader

(D) Application ClassLoader

Correct Answer: (B)

[EN] A ClassLoader delegates the load request upward through Platform to the Bootstrap ClassLoader first; only if parents cannot find the class does the child attempt loading.

[HI] ClassLoader पहले अनुरोध को Platform से होते हुए Bootstrap ClassLoader तक ऊपर भेजता है; पेरेंट्स द्वारा क्लास न मिलने पर ही चाइल्ड लोडर उसे लोड करता है।

Q8. How big is each JVM bytecode opcode in the instruction set?

(JVM निर्देश सेट में प्रत्येक बाइटकोड ऑपकोड का आकार कितना होता है?)

(A) 4 bytes (32 bits)

(B) 2 bytes (16 bits)

(C) 1 byte (8 bits)

(D) 8 bytes (64 bits)

Correct Answer: (C)

[EN] JVM bytecode instructions use 1-byte opcodes, restricting the theoretical maximum number of opcodes to 256.

[HI] JVM बाइटकोड निर्देश 1-बाइट ऑपकोड्स का उपयोग करते हैं, जिससे सैद्धांतिक अधिकतम ऑपकोड्स की संख्या 256 तक सीमित रहती है।

Q9. What value does a thread's Program Counter (PC) Register hold when the thread is currently executing a native method?

(जब कोई थ्रेड वर्तमान में एक native मेथड निष्पादित कर रहा हो, तो उस थ्रेड के Program Counter (PC) Register में क्या मान होता है?)

(A) Address of the next Java main() line

(B) Undefined

(C) Address of the Heap start

(D) 0xCAFEBABE

Correct Answer: (B)

[EN] According to the JVM Specification, the PC Register holds the address of the currently executing JVM instruction, or is undefined if the current method is native.

[HI] JVM विनिर्देश के अनुसार, PC Register वर्तमान JVM निर्देश का पता रखता है, परंतु यदि वर्तमान मेथड native हो तो इसका मान अपरिभाषित (undefined) होता है।

Q10. Which error is thrown if an application performs infinite recursion without a base condition in Java?

(यदि कोई एप्लिकेशन जावा में बिना बेस कंडीशन के अनंत रिकर्शन करता है, तो कौन सी एरर उत्पन्न होती है?)

(A) java.lang.StackOverflowError

(B) java.lang.ClassFormatError

(C) java.lang.OutOfMemoryError

(D) java.lang.VerifyError

Correct Answer: (A)

[EN] Each recursive call pushes a new stack frame onto the thread's private JVM Stack until its fixed depth limit is exhausted, throwing StackOverflowError.

[HI] प्रत्येक रिकर्सिव कॉल थ्रेड के निजी JVM Stack में एक नया फ़्रेम जोड़ता है; सीमा समाप्त होने पर StackOverflowError उत्पन्न होता है।

Q11. Which component enables Java bytecode to invoke functions written in C or C++ libraries?

(कौन सा घटक जावा बाइटकोड को C या C++ लाइब्रेरी में लिखे गए फ़ंक्शंस को कॉल करने में सक्षम बनाता है?)

(A) Java Management Extensions (JMX)

(B) Tiered C2 Compiler

(C) Bytecode Verifier

(D) Java Native Interface (JNI)

Correct Answer: (D)

[EN] Java Native Interface (JNI) acts as the bridge between the JVM Execution Engine and platform-specific Native Method Libraries.

[HI] Java Native Interface (JNI) JVM Execution Engine और प्लेटफॉर्म-विशिष्ट नेटिव मेथड लाइब्रेरी के बीच सेतु का कार्य करता है।

Q12. Which optimization performed by the HotSpot C2 JIT compiler allocates non-escaping objects on the stack or removes synchronization locks?

(HotSpot C2 JIT कंपाइलर द्वारा किया जाने वाला कौन सा अनुकूलन नॉन-एस्केपिंग ऑब्जेक्ट्स को स्टैक पर आवंटित करता है या सिंक्रोनाइज़ेशन लॉक हटाता है?)

(A) Parent Delegation

(B) Class Verification

(C) Escape Analysis

(D) Symbolic Resolution

Correct Answer: (C)

[EN] Escape Analysis determines whether an object's reference never leaves a method or thread, enabling scalar replacement, stack allocation, and lock elision.

[HI] Escape Analysis यह जांचता है कि क्या किसी ऑब्जेक्ट का रेफरेंस मेथड या थ्रेड से बाहर नहीं जाता, जिससे स्टैक एलोकेशन और लॉक एलिशन संभव होता है।

Q13. In the JVM stack frame, which structure holds temporary operands and intermediate results for bytecode instructions?

(JVM स्टैक फ़्रेम में कौन सी संरचना बाइटकोड निर्देशों के अस्थायी ऑपरेंड और मध्यवर्ती परिणामों को रखती है?)

(A) Operand Stack

(B) Garbage Collector Queue

(C) Metaspace

(D) String Constant Pool

Correct Answer: (A)

[EN] Each stack frame contains a Local Variable Array, an Operand Stack for LIFO computation, and Frame Data referencing the constant pool.

[HI] प्रत्येक स्टैक फ़्रेम में Local Variable Array, LIFO गणना के लिए Operand Stack और कांस्टेंट पूल संदर्भ वाला Frame Data होता है।

Q14. What distinguishes JDK from JRE and JVM in the Java platform hierarchy?

(जावा प्लेटफॉर्म पदानुक्रम में JDK, JRE और JVM से किस प्रकार भिन्न है?)

(A) JDK only provides the Garbage Collector without runtime libraries

(B) JRE includes javac but excludes the JVM

(C) JDK contains JRE plus development tools like javac and jdb

(D) JVM contains JDK plus the Java compiler

Correct Answer: (C)

[EN] JVM executes bytecode; JRE bundles JVM with core runtime libraries; JDK wraps JRE together with developer tools such as javac, javadoc, and jdb.

[HI] JVM बाइटकोड चलाता है; JRE में JVM और कोर रनटाइम लाइब्रेरी होती हैं; जबकि JDK में JRE के साथ javac, javadoc और jdb जैसे डेवलपर टूल्स शामिल होते हैं।

Q15. Which phase replaces symbolic class, field, and method names in the constant pool with direct memory pointers?

(कौन सा चरण कांस्टेंट पूल में मौजूद प्रतीकात्मक क्लास, फ़ील्ड और मेथड नामों को डायरेक्ट मेमोरी पॉइंटर्स से बदलता है?)

(A) Resolution

(B) Garbage Collection

(C) Verification

(D) Preparation

Correct Answer: (A)

[EN] Resolution (the third sub-step of Linking) transforms symbolic references in the runtime constant pool into direct pointers.

[HI] Resolution (Linking का तीसरा उप-चरण) रनटाइम कांस्टेंट पूल में प्रतीकात्मक संदर्भों को डायरेक्ट पॉइंटर्स में परिवर्तित करता है।

Q16. Which of the following statements about the JVM is NOT true?

(JVM के बारे में निम्नलिखित में से कौन सा कथन सत्य नहीं है?)

(A) JVM creates a separate JVM Stack for every newly started Java thread

(B) JVM provides automatic memory reclamation via Garbage Collection

(C) JVM itself is platform-independent and identical in binary form on Windows and Linux

(D) JVM executes .class bytecode files produced by javac

Correct Answer: (C)

[EN] Bytecode (.class) is platform-independent, whereas the JVM executable itself is platform-dependent—Windows, Linux, and macOS require OS-specific JVM builds.

[HI] बाइटकोड (.class) प्लेटफॉर्म-स्वतंत्र होता है, जबकि स्वयं JVM प्लेटफॉर्म-निर्भर होता है—Windows, Linux और macOS के लिए अलग-अलग OS-विशिष्ट JVM बिल्ड आवश्यक होते हैं।

Q17. Within Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT, which jvm subsystem / component directly maps to: "Loads core JDK classes like java.lang.String"?

(Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT में कौन सा JVM Subsystem / Component सीधे "Loads core JDK classes like java.lang.String" से संबंधित है?)

(A) Bootstrap ClassLoader

(B) Bytecode Verifier

(C) JIT Compiler

(D) JVM Heap Area

Correct Answer: (A)

[EN] In Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT, 'Bootstrap ClassLoader' handles 'Loads core JDK classes like java.lang.String' (Written in native C/C++; getClassLoader() returns null).

[HI] Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT में 'Bootstrap ClassLoader' का कार्य/विवरण 'Loads core JDK classes like java.lang.String' (Written in native C/C++; getClassLoader() returns null) है।

Q18. Which option accurately describes 'Bytecode Verifier' in Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT?

(Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT के संदर्भ में 'Bytecode Verifier' की सही विशेषता कौन सी है?)

(A) Loads core JDK classes like java.lang.String

(B) Stores all runtime objects and arrays across threads

(C) Compiles frequently executed hotspot methods to native code

(D) Validates stack discipline, type safety, and format

Correct Answer: (D)

[EN] 'Bytecode Verifier' provides 'Validates stack discipline, type safety, and format' — key point: Checks 4-byte 0xCAFEBABE magic header during Linking.

[HI] 'Bytecode Verifier' का मुख्य विवरण 'Validates stack discipline, type safety, and format' है (Checks 4-byte 0xCAFEBABE magic header during Linking)।

Q19. In Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT, identify the correct parameter for the specification: "Compiles frequently executed hotspot methods to native code".

(Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT में "Compiles frequently executed hotspot methods to native code" विवरण किस विकल्प के लिए सही है?)

(A) Bootstrap ClassLoader

(B) JVM Heap Area

(C) JIT Compiler

(D) Bytecode Verifier

Correct Answer: (C)

[EN] 'JIT Compiler' corresponds to 'Compiles frequently executed hotspot methods to native code' (Uses C1/C2 tiered compilation, inlining, and escape analysis).

[HI] 'JIT Compiler' का संबंध 'Compiles frequently executed hotspot methods to native code' (Uses C1/C2 tiered compilation, inlining, and escape analysis) से है।

Q20. Considering Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT, what key behavior defines 'JVM Heap Area'?

(Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT में 'JVM Heap Area' की मुख्य भूमिका या मान क्या है?)

(A) Validates stack discipline, type safety, and format

(B) Loads core JDK classes like java.lang.String

(C) Stores all runtime objects and arrays across threads

(D) Compiles frequently executed hotspot methods to native code

Correct Answer: (C)

[EN] 'JVM Heap Area' represents 'Stores all runtime objects and arrays across threads' (Managed by Garbage Collector; overflow throws OutOfMemoryError).

[HI] 'JVM Heap Area' का अर्थ/मान 'Stores all runtime objects and arrays across threads' है (Managed by Garbage Collector; overflow throws OutOfMemoryError)।

Java Virtual Machine (JVM): ClassLoader, Bytecode, Execution Engine, JIT — Exam FAQs

Q1: Why is Java called platform-independent even though the JVM is platform-dependent?

JVM प्लेटफॉर्म-निर्भर होने के बावजूद जावा को प्लेटफॉर्म-स्वतंत्र क्यों कहा जाता है?

[EN] Java source code compiles once into standardized .class bytecode using the fixed JVM Specification. Every OS has its own native JVM implementation that translates that identical bytecode into local CPU instructions, achieving Write Once, Run Anywhere (WORA).

[HI] जावा सोर्स कोड एक बार मानकीकृत .class बाइटकोड में संकलित होता है। प्रत्येक ऑपरेटिंग सिस्टम पर मौजूद उसका नेटिव JVM उस समान बाइटकोड को स्थानीय CPU निर्देशों में बदल देता है, जिससे 'Write Once, Run Anywhere' संभव होता है।

Q2: How do the Interpreter and JIT compiler cooperate inside HotSpot JVM?

HotSpot JVM के भीतर Interpreter और JIT कंपाइलर एक साथ कैसे काम करते हैं?

[EN] The Interpreter immediately executes bytecode on startup without compilation delay, while HotSpot profiles execution counts. Frequently invoked methods and loops cross a threshold and are compiled asynchronously by the JIT (C1/C2) into cached native code.

[HI] Interpreter बिना संकलन विलंब के स्टार्टअप पर तुरंत बाइटकोड चलाता है, जबकि HotSpot निष्पादन गणना को ट्रैक करता है। बार-बार चलने वाले मेथड्स और लूप्स सीमा पार करते ही JIT (C1/C2) द्वारा कैश्ड नेटिव कोड में संकलित हो जाते हैं।

Q3: What happens if two ClassLoaders load the exact same .class file in one JVM?

यदि एक ही JVM में दो अलग-अलग ClassLoaders एक ही .class फ़ाइल को लोड करें तो क्या होता है?

[EN] In the JVM, a class's runtime identity is defined by the pair (fully qualified class name, defining ClassLoader). Therefore, the two loaded types are treated as distinct incompatible classes, and casting between their instances throws ClassCastException.

[HI] JVM में किसी क्लास की रनटाइम पहचान (पूर्ण क्लास नाम, परिभाषित ClassLoader) के युग्म से होती है। अतः दोनों लोड की गई क्लासेस अलग-अलग और असंगत मानी जाती हैं, और उनके ऑब्जेक्ट्स की कास्टिंग पर ClassCastException आता है।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)