Java Architecture: JDK, JRE and JVM Differences Notes in Hindi & English : जावा आर्किटेक्चर: JDK (डेवलपमेंट), JRE (रनटाइम) और JVM और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

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

Overview: Java's architecture forms a strict containment hierarchy where the JDK (Java Development Kit) contains the JRE plus developer tools, and the JRE (Java Runtime Environment) contains the JVM plus core runtime libraries. Together they convert .java source files into .class bytecode and execute them reliably across platforms.

अध्याय सार: जावा का आर्किटेक्चर एक स्तरीय संरचना है जहाँ JDK (Java Development Kit) में JRE व डेवलपमेंट टूल्स होते हैं, और JRE (Java Runtime Environment) में JVM व कोर लाइब्रेरीज़ शामिल होती हैं। यह पूरा तंत्र .java कोड को .class बाइटकोड में बदलकर प्लेटफॉर्म-इंडिपेंडेंट रूप से निष्पादित करता है।

Java Architecture: JDK, JRE and JVM Differences: Detailed Notes & Architecture (जावा आर्किटेक्चर: JDK (डेवलपमेंट), JRE (रनटाइम) और JVM)

1. JVM (Java Virtual Machine) Subsystems and Memory Areas (JVM (Java Virtual Machine) की आंतरिक संरचना और मेमोरी क्षेत्र)

[EN] The JVM is an abstract execution specification realized per OS that loads, verifies, and runs Java bytecode. Internally it consists of three pillars: (1) ClassLoader Subsystem (performing Loading, Linking [Verify, Prepare, Resolve], and Initialization), (2) Runtime Data Areas—split into shared areas (Heap for objects, Method Area/Metaspace for class metadata) and per-thread areas (JVM Stack, PC Register, Native Method Stack)—and (3) Execution Engine (Interpreter, JIT Compiler, Garbage Collector).

[HI] JVM एक वर्चुअल मशीन है जो किसी भी OS पर जावा बाइटकोड को लोड, सत्यापित और निष्पादित करती है। इसके तीन मुख्य भाग हैं: (1) ClassLoader सबसिस्टम (Loading, Linking और Initialization), (2) Runtime Data Areas—जिसमें Heap (ऑब्जेक्ट्स) व Method Area सभी थ्रेड्स में साझा रहते हैं जबकि JVM Stack, PC Register व Native Stack प्रत्येक थ्रेड के लिए अलग होते हैं, तथा (3) Execution Engine (इंटरप्रेटर, JIT कंपाइलर व गार्बेज कलेक्टर)।

2. JRE (Java Runtime Environment) Role and Contents (JRE (Java Runtime Environment) की भूमिका और घटक)

[EN] The JRE provides the minimum environment required solely to run already-compiled Java applications, formally expressed as JRE = JVM + Core Class Libraries (such as java.lang, java.util, java.io) + supporting configuration files. Because a standalone JRE lacks development tools like javac and jdb, an end user with only JRE can execute .jar files but cannot compile .java source code. From Java 11 onward, Oracle retired the separate public JRE installer in favor of JDK + jlink custom runtimes.

[HI] JRE पहले से कंपाइल किए गए जावा प्रोग्राम को केवल चलाने (run) का वातावरण देता है, जिसका सूत्र है: JRE = JVM + Core Class Libraries + सपोर्टिंग फाइलें। इसमें javac या jdb जैसे डेवलपमेंट टूल्स नहीं होते, इसलिए केवल JRE वाला यूजर .jar प्रोग्राम चला सकता है पर .java कोड कंपाइल नहीं कर सकता। Java 11 के बाद ओरेकल ने अलग JRE डाउनलोड बंद कर दिया और jlink से कस्टम रनटाइम बनाने की सुविधा दी।

3. JDK (Java Development Kit) and Core CLI Tools (JDK (Java Development Kit) और मुख्य डेवलपर टूल्स)

[EN] The JDK is the complete software development kit satisfying JDK = JRE + Development Tools, creating the strict subset hierarchy JVM < JRE < JDK. Inside JDK/bin reside essential utilities: javac (Java compiler emitting .class bytecode), java (application launcher starting the JVM), javap (bytecode disassembler), javadoc (HTML API documentation generator), jar (archive packager), and jdb (debugger). Every Java programmer writing and compiling code must install the JDK.

[HI] JDK (Java Development Kit) जावा एप्लिकेशन बनाने का पूरा पैकेज है: JDK = JRE + डेवलपमेंट टूल्स, अर्थात JVM ⊂ JRE ⊂ JDK। इसके bin फोल्डर में javac (कंपाइलर), java (लॉन्चर), javap (बाइटकोड डिसअसेंबलर), javadoc (डॉक्यूमेंटेशन टूल), jar (आर्काइवर) और jdb (डीबगर) जैसे प्रमुख टूल्स रहते हैं। कोड लिखने और कंपाइल करने वाले प्रत्येक डेवलपर के लिए JDK अनिवार्य है।

4. End-to-End Compilation and Execution Pipeline (कंपाइलेशन से निष्पादन तक की संपूर्ण प्रक्रिया)

[EN] Running javac HelloArch.java compiles source code into a HelloArch.class file beginning with the 4-byte magic header 0xCAFEBABE. Invoking java HelloArch starts the JVM, where ClassLoaders (Bootstrap, Platform/Extension, Application) follow the Parent Delegation Model to load bytecode securely. Finally, the Execution Engine interprets bytecode while the JIT Compiler optimizes hot loops into fast native machine code.

[HI] javac HelloArch.java चलाने पर सोर्स कोड HelloArch.class बाइटकोड में बदलता है, जिसके शुरुआती 4 बाइट मैजिक हेडर 0xCAFEBABE होते हैं। फिर java HelloArch चलाने पर JVM शुरू होता है और Bootstrap, Platform तथा Application ClassLoader पैरेंट डेलीगेशन मॉडल से क्लास लोड करते हैं। अंत में Execution Engine का इंटरप्रेटर और JIT कंपाइलर मिलकर कोड को तेजी से निष्पादित करते हैं।

Syntax, Formula & Technical Example (Java Architecture: JDK, JRE and JVM Differences)

// Compile with JDK: javac HelloArch.java -> HelloArch.class
// Inspect bytecode: javap -c HelloArch
// Execute via JRE/JVM: java HelloArch
public class HelloArch {
    public static void main(String[] args) {
        System.out.println("JDK > JRE > JVM");
        System.out.println(System.getProperty("java.vm.name"));
    }
}

Java Architecture: JDK, JRE and JVM Differences Quick Reference & Comparison Table

Architecture LayerFormula / ComponentsExam Key Point
JVMClassLoader + Runtime Areas + EngineExecutes bytecode; physically OS-dependent
JREJVM + Core Class Libraries (rt.jar/mods)Runs Java apps; lacks javac compiler
JDKJRE + Dev Tools (javac, jdb, javadoc)Superset required to write & compile Java
JIT CompilerHotspot optimizer inside Execution EngineCompiles hot bytecode into native machine code

Java Architecture: JDK, JRE and JVM Differences Top 20 Bilingual MCQs with Answers

Q1. Which mathematical containment hierarchy accurately represents JDK, JRE, and JVM?

(JDK, JRE और JVM के बीच सही समावेशन (containment) संबंध कौन-सा है?)

(A) JRE and JDK are completely disjoint packages

(B) JDK is inside JRE, and JRE is inside JVM

(C) JVM is inside JRE, and JRE is inside JDK (JVM < JRE < JDK)

(D) JVM contains JDK and JRE separately

Correct Answer: (C)

[EN] JDK = JRE + Development Tools, and JRE = JVM + Runtime Class Libraries, making JDK the superset.

[HI] JDK = JRE + डेवलपमेंट टूल्स और JRE = JVM + क्लास लाइब्रेरीज़ होता है, अतः क्रम JVM < JRE < JDK है।

Q2. If a machine has ONLY the JRE installed (and NOT the JDK), what can it do?

(यदि किसी कंप्यूटर पर केवल JRE इंस्टॉल है (JDK नहीं), तो वह क्या कर सकता है?)

(A) Neither compile nor run Java programs

(B) Generate HTML docs via javadoc and debug via jdb

(C) Compile .java files using javac, but cannot run them

(D) Run pre-compiled .class and .jar applications, but cannot compile .java source files

Correct Answer: (D)

[EN] The JRE omits javac and other developer binaries, supporting execution only.

[HI] JRE में javac कंपाइलर नहीं होता, इसलिए वह केवल पहले से बनी .class/.jar फाइलें चला सकता है, सोर्स कोड कंपाइल नहीं कर सकता।

Q3. Which JDK command-line tool compiles .java source files into .class bytecode?

(JDK का कौन-सा कमांड-लाइन टूल .java सोर्स फाइलों को .class बाइटकोड में कंपाइल करता है?)

(A) jdb

(B) java

(C) javac

(D) javap

Correct Answer: (C)

[EN] javac is the Java compiler; java launches the JVM, javap disassembles bytecode, and jdb is the debugger.

[HI] javac जावा कंपाइलर है जो सोर्स कोड से .class बाइटकोड बनाता है (जबकि java उसे चलाने का लॉन्चर है)।

Q4. Which two JVM Runtime Data Areas are shared across ALL threads in a Java process?

(JVM के कौन-से दो Runtime Data Areas एक जावा प्रक्रिया के सभी थ्रेड्स द्वारा साझा (shared) किए जाते हैं?)

(A) PC Register and Method Area

(B) Native Method Stack and Heap

(C) JVM Stack and PC Register

(D) Heap and Method Area

Correct Answer: (D)

[EN] Heap (holding objects) and Method Area (class metadata) are shared globally; Stack, PC Register, and Native Stack are per-thread.

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

Q5. Where in JVM memory are objects created with the 'new' keyword dynamically allocated?

(जावा में 'new' कीवर्ड द्वारा बनाए गए ऑब्जेक्ट्स JVM की किस मेमोरी में आवंटित होते हैं?)

(A) Heap

(B) JVM Stack

(C) PC Register

(D) Native Method Stack

Correct Answer: (A)

[EN] All class instances and arrays allocated at runtime reside in the shared Heap managed by the Garbage Collector.

[HI] रनटाइम पर new से बनने वाले सभी ऑब्जेक्ट्स और एरे साझा Heap मेमोरी में बनते हैं।

Q6. Which 4-byte hexadecimal magic number appears at the very beginning of every valid Java .class file?

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

(A) 0x7F454C46

(B) 0x4D5A9000

(C) 0xDEADBEEF

(D) 0xCAFEBABE

Correct Answer: (D)

[EN] Every compiled Java class file starts with the signature 0xCAFEBABE (whereas ELF uses 0x7F454C46 and PE uses 0x4D5A).

[HI] प्रत्येक जावा .class फाइल 0xCAFEBABE मैजिक नंबर से शुरू होती है जिससे JVM इसकी पहचान करता है।

Q7. Which JDK tool is used to disassemble a compiled .class file and inspect its bytecode instructions?

(कंपाइल हो चुकी .class फाइल को डिसअसेंबल करके उसके बाइटकोड निर्देश देखने के लिए किस JDK टूल का उपयोग होता है?)

(A) jconsole

(B) jarsigner

(C) javap

(D) javadoc

Correct Answer: (C)

[EN] Running javap -c ClassName prints the disassembled JVM bytecode instructions of each method.

[HI] javap (जैसे javap -c ClassName) का उपयोग .class फाइल का बाइटकोड पढ़ने के लिए किया जाता है।

Q8. Which subsystem inside the JVM Execution Engine compiles frequently executed bytecode into native CPU code?

(JVM Execution Engine का कौन-सा भाग बार-बार चलने वाले बाइटकोड को सीधे नेटिव CPU मशीन कोड में बदलता है?)

(A) javac Frontend

(B) JIT (Just-In-Time) Compiler

(C) PC Register

(D) Bootstrap ClassLoader

Correct Answer: (B)

[EN] The JIT Compiler identifies hot methods at runtime and translates them to optimized native instructions.

[HI] JIT (Just-In-Time) कंपाइलर रनटाइम पर अधिक उपयोग होने वाले बाइटकोड को तेज नेटिव मशीन कोड में कंपाइल करता है।

Q9. What are the three sub-phases of the Linking stage in the JVM ClassLoader subsystem?

(JVM ClassLoader के Linking चरण के तीन उप-चरण सही क्रम में कौन-से हैं?)

(A) Parsing, Tokenizing, Packing

(B) Verification, Preparation, Resolution

(C) Allocation, Marking, Sweeping

(D) Compilation, Interpretation, Execution

Correct Answer: (B)

[EN] Class loading progresses through Loading -> Linking (Verification, Preparation, Resolution) -> Initialization.

[HI] क्लास लोडिंग के दौरान Linking चरण तीन उप-चरणों—Verification, Preparation और Resolution—से गुजरता है।

Q10. Which ClassLoader sits at the top of the hierarchy and loads core Java classes like java.lang.String?

(क्लासलोडर पदानुक्रम में सबसे ऊपर कौन होता है जो java.lang.String जैसी कोर जावा क्लासेस लोड करता है?)

(A) Extension / Platform ClassLoader

(B) Application (System) ClassLoader

(C) Custom Network ClassLoader

(D) Bootstrap ClassLoader

Correct Answer: (D)

[EN] The native Bootstrap ClassLoader loads core JDK modules (java.base / rt.jar) and serves as the root parent.

[HI] Bootstrap ClassLoader पदानुक्रम में सर्वोच्च है और यह java.lang जैसी मूल कोर जावा क्लासेस लोड करता है।

Q11. Where are local primitive variables and method invocation stack frames stored inside the JVM?

(JVM के भीतर मेथड कॉल फ्रेम्स और लोकल प्रिमिटिव वेरिएबल्स कहाँ संग्रहीत होते हैं?)

(A) JVM Stack (per thread)

(B) Constant Pool only

(C) Heap

(D) Method Area

Correct Answer: (A)

[EN] Each thread creates a private JVM Stack holding frames for active method calls, local variables, and operand stacks.

[HI] प्रत्येक थ्रेड का अपना निजी JVM Stack होता है जिसमें सक्रिय मेथड फ्रेम और लोकल वेरिएबल्स रखे जाते हैं।

Q12. Which JVM register holds the memory address of the currently executing bytecode instruction for a thread?

(JVM का कौन-सा घटक किसी थ्रेड में वर्तमान में चल रहे बाइटकोड निर्देश का पता (address) रखता है?)

(A) Static Frame Table

(B) PC (Program Counter) Register

(C) Class Index Register

(D) Heap Pointer

Correct Answer: (B)

[EN] Each non-native Java thread has its own PC Register tracking the current JVM instruction offset.

[HI] प्रत्येक थ्रेड का अपना PC (Program Counter) Register होता है जो वर्तमान बाइटकोड निर्देश का पता ट्रैक करता है।

Q13. Starting with Java 11, how did Oracle change public distribution of the standalone JRE?

(Java 11 से ओरेकल ने स्टैंडअलोन JRE के सार्वजनिक वितरण में क्या बदलाव किया?)

(A) Standalone public JRE downloads were discontinued in favor of JDK and jlink custom runtimes

(B) JRE was renamed to JVM Lite and made mandatory

(C) javac was moved inside the JRE

(D) JDK was discontinued and merged into JRE

Correct Answer: (A)

[EN] Since Java 11, users download the JDK or build slim custom runtime images with the jlink tool.

[HI] Java 11 से अलग सार्वजनिक JRE डाउनलोड बंद कर दिया गया और डेवलपर्स JDK या jlink से कस्टम रनटाइम बनाते हैं।

Q14. Which JDK tool generates HTML API documentation pages directly from /** ... */ source comments?

(सोर्स कोड के /** ... */ कमेंट्स से सीधे HTML API डॉक्यूमेंटेशन बनाने के लिए कौन-सा JDK टूल उपयोग होता है?)

(A) javap

(B) javah

(C) javadoc

(D) jar

Correct Answer: (C)

[EN] javadoc parses doc comments to produce structured HTML documentation for packages, classes, and methods.

[HI] javadoc टूल विशेष डॉक्यूमेंटेशन कमेंट्स को पढ़कर जावा कोड के लिए HTML API डॉक्यूमेंटेशन तैयार करता है।

Q15. Which statement about JDK, JRE, and JVM is NOT true?

(JDK, JRE और JVM के विषय में निम्नलिखित में से कौन-सा कथन असत्य है?)

(A) JDK includes everything inside JRE along with javac and jdb

(B) The JVM specification and binary implementations are physically identical across Windows and Linux

(C) Garbage Collection operates within the JVM Execution Engine on Heap objects

(D) JRE includes the JVM plus standard runtime class libraries

Correct Answer: (B)

[EN] While the JVM specification is uniform, actual JVM binaries (like jvm.dll vs libjvm.so) are platform-dependent per OS.

[HI] JVM का विनिर्देश समान होने पर भी इसके वास्तविक बाइनरी इम्प्लीमेंटेशन विंडोज और लिनक्स के लिए अलग-अलग (प्लेटफ़ॉर्म-डिपेंडेंट) होते हैं।

Q16. In Java architecture, which tool packs multiple .class files and resources into a single distributable archive?

(जावा आर्किटेक्चर में कई .class फाइलों और संसाधनों को एक वितरित करने योग्य आर्काइव फाइल में पैक करने का टूल कौन-सा है?)

(A) jar

(B) javap

(C) jdb

(D) jps

Correct Answer: (A)

[EN] The jar (Java Archive) tool bundles compiled classes, manifests, and resources into .jar ZIP-format archives.

[HI] jar (Java Archive) टूल कंपाइल हो चुकी क्लासेस व संसाधनों को एक .jar फाइल में पैक करता है।

Q17. Within Java Architecture: JDK, JRE and JVM Differences, which architecture layer directly maps to: "ClassLoader + Runtime Areas + Engine"?

(Java Architecture: JDK, JRE and JVM Differences में कौन सा Architecture Layer सीधे "ClassLoader + Runtime Areas + Engine" से संबंधित है?)

(A) JVM

(B) JRE

(C) JIT Compiler

(D) JDK

Correct Answer: (A)

[EN] In Java Architecture: JDK, JRE and JVM Differences, 'JVM' handles 'ClassLoader + Runtime Areas + Engine' (Executes bytecode; physically OS-dependent).

[HI] Java Architecture: JDK, JRE and JVM Differences में 'JVM' का कार्य/विवरण 'ClassLoader + Runtime Areas + Engine' (Executes bytecode; physically OS-dependent) है।

Q18. Which option accurately describes 'JRE' in Java Architecture: JDK, JRE and JVM Differences?

(Java Architecture: JDK, JRE and JVM Differences के संदर्भ में 'JRE' की सही विशेषता कौन सी है?)

(A) Hotspot optimizer inside Execution Engine

(B) JVM + Core Class Libraries (rt.jar/mods)

(C) ClassLoader + Runtime Areas + Engine

(D) JRE + Dev Tools (javac, jdb, javadoc)

Correct Answer: (B)

[EN] 'JRE' provides 'JVM + Core Class Libraries (rt.jar/mods)' — key point: Runs Java apps; lacks javac compiler.

[HI] 'JRE' का मुख्य विवरण 'JVM + Core Class Libraries (rt.jar/mods)' है (Runs Java apps; lacks javac compiler)।

Q19. In Java Architecture: JDK, JRE and JVM Differences, identify the correct parameter for the specification: "JRE + Dev Tools (javac, jdb, javadoc)".

(Java Architecture: JDK, JRE and JVM Differences में "JRE + Dev Tools (javac, jdb, javadoc)" विवरण किस विकल्प के लिए सही है?)

(A) JVM

(B) JRE

(C) JIT Compiler

(D) JDK

Correct Answer: (D)

[EN] 'JDK' corresponds to 'JRE + Dev Tools (javac, jdb, javadoc)' (Superset required to write & compile Java).

[HI] 'JDK' का संबंध 'JRE + Dev Tools (javac, jdb, javadoc)' (Superset required to write & compile Java) से है।

Q20. Considering Java Architecture: JDK, JRE and JVM Differences, what key behavior defines 'JIT Compiler'?

(Java Architecture: JDK, JRE and JVM Differences में 'JIT Compiler' की मुख्य भूमिका या मान क्या है?)

(A) ClassLoader + Runtime Areas + Engine

(B) JVM + Core Class Libraries (rt.jar/mods)

(C) Hotspot optimizer inside Execution Engine

(D) JRE + Dev Tools (javac, jdb, javadoc)

Correct Answer: (C)

[EN] 'JIT Compiler' represents 'Hotspot optimizer inside Execution Engine' (Compiles hot bytecode into native machine code).

[HI] 'JIT Compiler' का अर्थ/मान 'Hotspot optimizer inside Execution Engine' है (Compiles hot bytecode into native machine code)।

Java Architecture: JDK, JRE and JVM Differences — Exam FAQs

Q1: Can I run a Java program if I only install the JDK without separately installing a JRE?

क्या अलग से JRE इंस्टॉल किए बिना केवल JDK इंस्टॉल करके जावा प्रोग्राम चलाया जा सकता है?

[EN] Yes. Because the JDK already contains a complete JRE (and JVM) inside it, installing the JDK gives you everything needed to both compile and run Java applications.

[HI] हाँ। चूंकि JDK के अंदर पहले से ही पूरा JRE और JVM शामिल होता है, इसलिए केवल JDK इंस्टॉल करने से आप प्रोग्राम कंपाइल और रन दोनों कर सकते हैं।

Q2: What happens if the JVM Heap runs out of memory while creating objects?

नए ऑब्जेक्ट बनाते समय यदि JVM Heap की मेमोरी पूरी भर जाए तो क्या होता है?

[EN] After running Garbage Collection to reclaim unreachable objects, if sufficient space still cannot be freed, the JVM throws java.lang.OutOfMemoryError.

[HI] पहले गार्बेज कलेक्टर अनुपयोगी ऑब्जेक्ट्स हटाकर जगह खाली करने का प्रयास करता है; फिर भी मेमोरी कम पड़ने पर JVM java.lang.OutOfMemoryError उत्पन्न करता है।

Q3: How does a JVM StackOverflowError differ from OutOfMemoryError?

JVM में StackOverflowError और OutOfMemoryError के बीच क्या अंतर है?

[EN] StackOverflowError happens when a thread's private JVM Stack fills up (typically due to unbounded recursion), whereas OutOfMemoryError happens when the shared Heap or Metaspace cannot allocate new objects.

[HI] StackOverflowError तब आता है जब अनंत रिकर्शन आदि के कारण किसी थ्रेड का निजी JVM Stack भर जाए, जबकि OutOfMemoryError मुख्यतः साझा Heap मेमोरी भर जाने पर आता है।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)