PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम First Java Program: public static void main(String[] args) Breakdown (जावा का पहला प्रोग्राम: public static void main का विस्तृत विश्लेषण) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: A standalone Java application starts execution from the entry-point method declared exactly as public static void main(String[] args). Each keyword—public, static, void, main, and the String[] parameter—satisfies a strict contract with the JVM launcher so the runtime can invoke the method without creating an instance.
अध्याय सार: एक स्टैंडअलोन जावा एप्लिकेशन का निष्पादन ठीक public static void main(String[] args) के रूप में घोषित एंट्री-पॉइंट मेथड से शुरू होता है। प्रत्येक कीवर्ड—public, static, void, main और String[] पैरामीटर—JVM लॉन्चर के साथ एक सख्त अनुबंध पूरा करता है ताकि रनटाइम बिना ऑब्जेक्ट बनाए मेथड को कॉल कर सके।
First Java Program: public static void main(String[] args) Breakdown: Detailed Notes & Architecture (जावा का पहला प्रोग्राम: public static void main का विस्तृत विश्लेषण)
1. Compilation and Execution Workflow of a First Java Program (पहले जावा प्रोग्राम का संकलन और निष्पादन कार्यप्रवाह)
[EN] Creating a Java program begins with writing source code inside a class saved in a .java file (if the class is declared public, the filename must exactly match the public class name, including case sensitivity). Running 'javac MainDemo.java' invokes the Java compiler, which checks syntax and type rules and emits a 'MainDemo.class' bytecode file. Running 'java MainDemo arg1 arg2' launches the JVM, loads MainDemo via the Application ClassLoader, verifies its bytecode, and searches specifically for the main(String[]) entry method. Since Java 11 (JEP 330), single-file source programs can also be executed directly with 'java MainDemo.java' in memory without manually producing a .class file on disk.
[HI] जावा प्रोग्राम बनाने के लिए कोड को .java फ़ाइल में किसी क्लास के भीतर लिखा जाता है (यदि क्लास public हो, तो फ़ाइल का नाम और क्लास का नाम केस-सेंसिटिविटी सहित बिल्कुल समान होना आवश्यक है)। 'javac MainDemo.java' चलाने पर जावा कंपाइलर सिंटैक्स व टाइप नियमों की जांच करके 'MainDemo.class' बाइटकोड फ़ाइल बनाता है। 'java MainDemo arg1 arg2' चलाने से JVM शुरू होता है, MainDemo क्लास लोड होती है, बाइटकोड सत्यापित होता है और विशेष रूप से main(String[]) एंट्री मेथड की खोज की जाती है। Java 11 (JEP 330) के बाद से एकल सोर्स फ़ाइल को बिना डिस्क पर .class फ़ाइल बनाए सीधे 'java MainDemo.java' से भी चलाया जा सकता है।
2. Meaning of public, static, and void Modifiers (public, static और void मॉडिफ़ायर्स का अर्थ)
[EN] The 'public' access specifier makes main accessible from outside its own package so the JVM launcher process can invoke it without access-control failure. The 'static' modifier binds main directly to the class rather than an object instance, allowing the JVM to invoke MainDemo.main(...) before any objects exist and avoiding ambiguity over constructor arguments. The 'void' return type specifies that main returns no value directly back to the JVM upon completion; any numeric process exit code must instead be signaled explicitly via System.exit(int status). If any of public, static, or void is omitted or altered (such as making main private or returning int), javac still compiles the code cleanly, but the java launcher throws a runtime Main method error.
[HI] 'public' एक्सेस स्पेसिफ़ायर main को उसके पैकेज से बाहर से भी सुलभ बनाता है ताकि JVM लॉन्चर बिना किसी एक्सेस अवरोध के उसे कॉल कर सके। 'static' मॉडिफ़ायर main को ऑब्जेक्ट के बजाय सीधे क्लास से जोड़ता है, जिससे JVM बिना ऑब्जेक्ट बनाए और कंस्ट्रक्टर आर्ग्युमेंट्स की दुविधा से बचे हुए MainDemo.main(...) को चला सके। 'void' रिटर्न टाइप दर्शाता है कि main समाप्त होने पर JVM को कोई मान वापस नहीं करता; ऑपरेटिंग सिस्टम को प्रोसेस एग्जिट कोड भेजने के लिए System.exit(int status) का उपयोग करना होता है। यदि public, static या void में से किसी को हटाया या बदला जाए, तो javac कोड को कंपाइल तो कर देगा लेकिन रनटाइम पर java लॉन्चर Main method न मिलने की त्रुटि देगा।
3. The main Identifier and String[] args Parameter (main पहचानकर्ता और String[] args पैरामीटर)
[EN] The identifier 'main' is not a reserved Java keyword; it is simply the conventional method name inspected by the JVM LauncherHelper when booting a program. Its single parameter, String[] args, receives command-line arguments passed after the class name as an array of String objects (never null when launched normally; if no arguments are supplied, args.length equals 0). Unlike C and C++, where argv[0] holds the executable name, Java sets args[0] to the first user-supplied argument, and the parameter identifier 'args' may legally be renamed to anything valid such as 'argv' or 'params'. Alternative array and varargs notations—including String args[], String... args, and swapping modifier order to 'static public void'—compile and execute identically.
[HI] 'main' कोई आरक्षित जावा कीवर्ड नहीं है; यह केवल JVM LauncherHelper द्वारा प्रोग्राम शुरू करते समय खोजा जाने वाला मानक मेथड नाम है। इसका एकमात्र पैरामीटर String[] args कमांड लाइन पर क्लास नाम के बाद दिए गए आर्ग्युमेंट्स को String एरे के रूप में प्राप्त करता है (सामान्य निष्पादन में यह कभी null नहीं होता; कोई आर्ग्युमेंट न होने पर args.length का मान 0 होता है)। C और C++ के विपरीत जहाँ argv[0] प्रोग्राम का नाम होता है, जावा में args[0] पहला यूज़र आर्ग्युमेंट होता है, और 'args' वेरिएबल का नाम बदलकर 'argv' या कुछ भी वैध रखा जा सकता है। String args[], String... args (varargs), तथा 'static public void' जैसे क्रम परिवर्तन भी बिल्कुल समान रूप से मान्य और निष्पादन योग्य हैं।
4. Overloading main, Valid Modifiers, and System.out.println (main ओवरलोडिंग, वैध मॉडिफ़ायर्स और System.out.println)
[EN] Because main is an ordinary static method to the compiler, a class can overload main with different parameter lists such as main(int x) or main(), though the JVM will only auto-invoke main(String[]). Additional non-conflicting modifiers like final, synchronized, and strictfp (prior to Java 17) are permitted on the main method declaration without breaking JVM discovery. Inside main, output is commonly written using System.out.println(), where System is a final class in java.lang, out is a static PrintStream field, and println() prints text followed by a newline. Note that System.out is automatically imported because the java.lang package is implicitly available in every Java source file.
[HI] कंपाइलर की दृष्टि से main एक सामान्य स्टैटिक मेथड है, इसलिए क्लास के भीतर main(int x) या main() जैसे ओवरलोडेड वर्जन बनाए जा सकते हैं, यद्यपि JVM स्वतः केवल main(String[]) को ही कॉल करेगा। JVM खोज को प्रभावित किए बिना main घोषणा पर final और synchronized जैसे अतिरिक्त वैध मॉडिफ़ायर्स भी लगाए जा सकते हैं। main के भीतर आउटपुट के लिए प्रयुक्त System.out.println() में System java.lang पैकेज की final क्लास है, out एक static PrintStream फ़ील्ड है, और println() न्यूलाइन सहित टेक्स्ट प्रिंट करता है। हर जावा फ़ाइल में java.lang पैकेज स्वतः इम्पोर्ट रहता है, इसलिए System के लिए अलग से import कथन की आवश्यकता नहीं होती।
Syntax, Formula & Technical Example (First Java Program: public static void main(String[] args) Breakdown)
public class FirstJavaProgram {
static public final void main(String... args) {
System.out.println("Hello, Java! Count = " + args.length);
if (args.length > 0) System.out.println("First: " + args[0]);
main(100); // Manual call to overloaded main
}
public static void main(int code) {
System.out.println("Overloaded main: " + code);
}
}
First Java Program: public static void main(String[] args) Breakdown Quick Reference & Comparison Table
| Signature Element | Technical Role in Java | Key Exam Fact |
|---|---|---|
| public | Grants universal package visibility to the JVM launcher | Private/protected main compiles but fails at runtime |
| static | Allows invocation directly on the class without object creation | Prevents ambiguity over parameterized constructors |
| void | Indicates no value is returned directly by main to JVM | Use System.exit(int) to pass OS exit status codes |
| String[] args | Captures space-separated command-line arguments as Strings | args[0] is the first argument, never the class name |
First Java Program: public static void main(String[] args) Breakdown Top 20 Bilingual MCQs with Answers
Q1. What happens if you declare the main method as 'private static void main(String[] args)' and compile and run it in Java 8+?
(यदि आप main मेथड को 'private static void main(String[] args)' घोषित करके Java 8+ में कंपाइल और रन करते हैं तो क्या होगा?)
(A) Throws NullPointerException before printing
(B) Compiles successfully, but throws a runtime error because the main method is not public
(C) Executes normally without any warning
(D) Fails to compile with illegal modifier error
Correct Answer: (B)
[EN] The Java compiler treats private main as an ordinary valid method, so javac succeeds; at runtime the java launcher rejects it because main must be public.
[HI] जावा कंपाइलर private main को एक सामान्य वैध मेथड मानकर कंपाइल कर देता है, परंतु रनटाइम पर java लॉन्चर इसे अस्वीकार कर त्रुटि देता है क्योंकि main का public होना अनिवार्य है।
Q2. Why must the entry-point main method be declared static?
(एंट्री-पॉइंट main मेथड को static घोषित करना क्यों आवश्यक है?)
(A) So that main cannot access static class variables
(B) So the JVM can invoke it directly via the class without instantiating an object
(C) So that subclasses cannot overload the method name
(D) So that main executes faster inside the Heap
Correct Answer: (B)
[EN] Making main static lets the JVM call ClassName.main(args) before any object exists and avoids guessing constructor parameters.
[HI] main को static रखने से JVM बिना किसी ऑब्जेक्ट को बनाए सीधे ClassName.main(args) को कॉल कर सकता है और कंस्ट्रक्टर पैरामीटर्स की समस्या से बचता है।
Q3. In 'java App alpha beta', what is the value of args[0] inside public static void main(String[] args)?
('java App alpha beta' कमांड में public static void main(String[] args) के अंदर args[0] का मान क्या होगा?)
(A) "java"
(B) "beta"
(C) "App"
(D) "alpha"
Correct Answer: (D)
[EN] Unlike C/C++ where argv[0] is the program name, Java places only user command-line arguments into args, making args[0] equal to "alpha".
[HI] C/C++ के विपरीत जहाँ argv[0] प्रोग्राम का नाम होता है, जावा में args में केवल यूज़र आर्ग्युमेंट्स जाते हैं, अतः args[0] का मान "alpha" होता है।
Q4. If no command-line arguments are passed when launching a Java program, what is args in main(String[] args)?
(जब किसी जावा प्रोग्राम को चलाते समय कोई कमांड-लाइन आर्ग्युमेंट न दिया जाए, तो main(String[] args) में args क्या होता है?)
(A) An empty String array of length 0
(B) null
(C) An array of length 1 containing the class name
(D) An uninitialized reference causing a compile error
Correct Answer: (A)
[EN] The JVM always constructs a non-null String array for main; when no arguments are supplied, args.length is 0.
[HI] JVM हमेशा main के लिए एक नॉन-null String एरे बनाता है; कोई आर्ग्युमेंट न होने पर args.length का मान 0 होता है।
Q5. Which of the following main method signatures is valid as the JVM entry point?
(निम्नलिखित में से कौन सा main मेथड सिग्नेचर JVM एंट्री पॉइंट के रूप में वैध है?)
(A) public static int main(String[] args)
(B) public void main(String[] args)
(C) static public final void main(String... cmdArgs)
(D) public static void Main(String[] args)
Correct Answer: (C)
[EN] Swapping public/static order, adding final, renaming the parameter, and using varargs (String... cmdArgs) are all valid; changing return type, removing static, or capitalizing Main breaks entry-point matching.
[HI] public/static का क्रम बदलना, final जोड़ना, पैरामीटर का नाम बदलना और varargs (String... cmdArgs) सभी वैध हैं; परंतु रिटर्न टाइप बदलना, static हटाना या Main में M बड़ा लिखना अमान्य है।
Q6. What is 'out' in the statement System.out.println("Hi");?
(System.out.println("Hi"); कथन में 'out' क्या है?)
(A) A static final PrintStream field defined in java.lang.System
(B) A reserved keyword for console output
(C) A static method in java.lang.System
(D) A local package inside java.io
Correct Answer: (A)
[EN] In java.lang.System, 'out' is a public static final reference field of type java.io.PrintStream, on which the println() method is called.
[HI] java.lang.System क्लास में 'out' java.io.PrintStream प्रकार का एक public static final फ़ील्ड है, जिस पर println() मेथड कॉल किया जाता है।
Q7. If a Java source file contains a public class named Calculator, what must the source filename be?
(यदि किसी जावा सोर्स फ़ाइल में Calculator नाम की public क्लास है, तो सोर्स फ़ाइल का नाम क्या होना चाहिए?)
(A) calculator.java
(B) Main.java
(C) Calculator.java
(D) Any valid filename ending in .class
Correct Answer: (C)
[EN] Java enforces that a file containing a public top-level class must have the exact same case-sensitive name followed by .java.
[HI] जावा का नियम है कि जिस फ़ाइल में कोई public टॉप-लेवल क्लास हो, उस फ़ाइल का नाम केस-सेंसिटिविटी सहित ठीक उसी क्लास के नाम के साथ .java होना चाहिए।
Q8. Can you overload the main method inside a single Java class?
(क्या आप एक ही जावा क्लास के भीतर main मेथड को ओवरलोड कर सकते हैं?)
(A) Yes, with different parameter lists, though JVM only auto-starts main(String[])
(B) No, because main is a reserved Java keyword
(C) No, Java forbids overloading any static method
(D) Yes, and the JVM automatically runs all overloaded versions sequentially
Correct Answer: (A)
[EN] Java allows overloading main (e.g., main(int), main()), because main is not a keyword; however, the JVM invokes only main(String[] args) at startup.
[HI] जावा में main को अलग-अलग पैरामीटर्स के साथ ओवरलोड किया जा सकता है क्योंकि main कोई कीवर्ड नहीं है; परंतु प्रोग्राम शुरू होने पर JVM स्वतः केवल main(String[] args) को ही चलाता है।
Q9. Which package is implicitly imported in every Java file, making System and String usable without import statements?
(प्रत्येक जावा फ़ाइल में कौन सा पैकेज स्वतः इम्पोर्ट होता है, जिससे बिना import कथन के System और String का उपयोग संभव होता है?)
(A) java.io
(B) java.lang
(C) java.util
(D) java.system
Correct Answer: (B)
[EN] The compiler automatically imports java.lang.* into every compilation unit so core classes like Object, String, System, and Math are directly accessible.
[HI] कंपाइलर प्रत्येक जावा सोर्स फ़ाइल में java.lang.* को स्वतः इम्पोर्ट कर देता है, जिससे Object, String, System और Math सीधे उपलब्ध रहते हैं।
Q10. How can a Java program explicitly pass a non-zero exit status code back to the operating system shell?
(एक जावा प्रोग्राम ऑपरेटिंग सिस्टम शेल को स्पष्ट रूप से नॉन-ज़ीरो एग्जिट स्टेटस कोड कैसे वापस भेज सकता है?)
(A) By changing main's return type to int and returning code
(B) By calling System.exit(code)
(C) By writing return code; inside void main
(D) By throwing a comment to javac
Correct Answer: (B)
[EN] Since main must return void, System.exit(int status) terminates the running JVM and passes the integer status code to the host OS.
[HI] चूंकि main का रिटर्न टाइप void होना आवश्यक है, इसलिए चलने वाले JVM को समाप्त करके OS को इंटीजर स्टेटस कोड भेजने हेतु System.exit(int status) का उपयोग किया जाता है।
Q11. Which command compiles Hello.java into Hello.class?
(कौन सा कमांड Hello.java को Hello.class में कंपाइल करता है?)
(A) java Hello.java
(B) javap Hello.java
(C) javac Hello.java
(D) jar Hello.java
Correct Answer: (C)
[EN] javac is the Java compiler tool in the JDK that translates .java source files into .class bytecode files.
[HI] javac JDK का जावा कंपाइलर टूल है जो .java सोर्स फ़ाइलों को .class बाइटकोड फ़ाइलों में अनुवादित करता है।
Q12. Which keyword CANNOT be legally combined with the standard JVM entry-point main declaration?
(निम्नलिखित में से कौन सा कीवर्ड मानक JVM एंट्री-पॉइंट main घोषणा के साथ वैध रूप से नहीं जोड़ा जा सकता?)
(A) abstract
(B) strictfp
(C) synchronized
(D) final
Correct Answer: (A)
[EN] An abstract method has no body and cannot be static; final and synchronized are legal on static methods like main.
[HI] abstract मेथड का कोई बॉडी ब्लॉक नहीं होता और वह static नहीं हो सकता; जबकि final और synchronized मुख्य स्टैटिक मेथड पर वैध हैं।
Q13. What happens if a single .java file contains three non-public classes A, B, and C, and you compile it with javac?
(यदि एक ही .java फ़ाइल में तीन नॉन-public क्लासेस A, B और C हैं और आप उसे javac से कंपाइल करते हैं, तो क्या होगा?)
(A) Only one combined file named A.class is generated
(B) The compiler generates three separate .class files: A.class, B.class, and C.class
(C) A compile-time error occurs because only one class is allowed per file
(D) The compiler merges all three classes into Main.class
Correct Answer: (B)
[EN] Every top-level class or interface inside a .java file compiles into its own separate ClassName.class bytecode file.
[HI] .java फ़ाइल के भीतर प्रत्येक टॉप-लेवल क्लास या इंटरफ़ेस के लिए कंपाइलर अलग-अलग ClassName.class बाइटकोड फ़ाइल उत्पन्न करता है।
Q14. What does 'System.out.print' do differently from 'System.out.println'?
('System.out.print' और 'System.out.println' में क्या अंतर है?)
(A) print accepts only Strings, whereas println accepts only ints
(B) print flushes automatically, whereas println never flushes
(C) print keeps the cursor on the same line, whereas println appends a line terminator
(D) print writes to stderr, whereas println writes to stdout
Correct Answer: (C)
[EN] Both write to standard output (System.out), but println appends the platform-specific line separator after printing the argument.
[HI] दोनों स्टैंडर्ड आउटपुट (System.out) पर लिखते हैं, परंतु println आउटपुट के बाद एक लाइन-सेपरेटर (नई पंक्ति) जोड़ देता है जबकि print कर्सर को उसी पंक्ति में रखता है।
Q15. In 'java Test 10 20', what is the expression args[0] + args[1] evaluated to inside main?
('java Test 10 20' चलाने पर main के अंदर args[0] + args[1] का मान क्या होगा?)
(A) Compile-time type mismatch error
(B) "1020"
(C) 30
(D) "30"
Correct Answer: (B)
[EN] Command-line arguments are always stored as String objects in args; the + operator performs String concatenation resulting in "1020".
[HI] कमांड-लाइन आर्ग्युमेंट्स हमेशा args में String के रूप में संग्रहीत होते हैं; अतः + ऑपरेटर स्ट्रिंग को जोड़कर "1020" परिणाम देता है।
Q16. Which statement about public static void main(String[] args) is FALSE?
(public static void main(String[] args) के संबंध में निम्नलिखित में से कौन सा कथन असत्य है?)
(A) Java supports writing 'String args[]' instead of 'String[] args'
(B) A Java file may have zero public classes and still contain a runnable main method
(C) The parameter name must always be written strictly as 'args'
(D) A non-static main method compiles cleanly without syntax errors
Correct Answer: (C)
[EN] The parameter name 'args' is merely an identifier convention and can be changed to any valid Java identifier such as inputs or argv.
[HI] पैरामीटर का नाम 'args' केवल एक परंपरा है; इसे बदलकर inputs या argv जैसा कोई भी वैध जावा पहचानकर्ता रखा जा सकता है।
Q17. Within First Java Program: public static void main(String[] args) Breakdown, which signature element directly maps to: "Grants universal package visibility to the JVM launcher"?
(First Java Program: public static void main(String[] args) Breakdown में कौन सा Signature Element सीधे "Grants universal package visibility to the JVM launcher" से संबंधित है?)
(A) String[] args
(B) public
(C) void
(D) static
Correct Answer: (B)
[EN] In First Java Program: public static void main(String[] args) Breakdown, 'public' handles 'Grants universal package visibility to the JVM launcher' (Private/protected main compiles but fails at runtime).
[HI] First Java Program: public static void main(String[] args) Breakdown में 'public' का कार्य/विवरण 'Grants universal package visibility to the JVM launcher' (Private/protected main compiles but fails at runtime) है।
Q18. Which option accurately describes 'static' in First Java Program: public static void main(String[] args) Breakdown?
(First Java Program: public static void main(String[] args) Breakdown के संदर्भ में 'static' की सही विशेषता कौन सी है?)
(A) Grants universal package visibility to the JVM launcher
(B) Indicates no value is returned directly by main to JVM
(C) Allows invocation directly on the class without object creation
(D) Captures space-separated command-line arguments as Strings
Correct Answer: (C)
[EN] 'static' provides 'Allows invocation directly on the class without object creation' — key point: Prevents ambiguity over parameterized constructors.
[HI] 'static' का मुख्य विवरण 'Allows invocation directly on the class without object creation' है (Prevents ambiguity over parameterized constructors)।
Q19. In First Java Program: public static void main(String[] args) Breakdown, identify the correct parameter for the specification: "Indicates no value is returned directly by main to JVM".
(First Java Program: public static void main(String[] args) Breakdown में "Indicates no value is returned directly by main to JVM" विवरण किस विकल्प के लिए सही है?)
(A) void
(B) String[] args
(C) public
(D) static
Correct Answer: (A)
[EN] 'void' corresponds to 'Indicates no value is returned directly by main to JVM' (Use System.exit(int) to pass OS exit status codes).
[HI] 'void' का संबंध 'Indicates no value is returned directly by main to JVM' (Use System.exit(int) to pass OS exit status codes) से है।
Q20. Considering First Java Program: public static void main(String[] args) Breakdown, what key behavior defines 'String[] args'?
(First Java Program: public static void main(String[] args) Breakdown में 'String[] args' की मुख्य भूमिका या मान क्या है?)
(A) Indicates no value is returned directly by main to JVM
(B) Grants universal package visibility to the JVM launcher
(C) Captures space-separated command-line arguments as Strings
(D) Allows invocation directly on the class without object creation
Correct Answer: (C)
[EN] 'String[] args' represents 'Captures space-separated command-line arguments as Strings' (args[0] is the first argument, never the class name).
[HI] 'String[] args' का अर्थ/मान 'Captures space-separated command-line arguments as Strings' है (args[0] is the first argument, never the class name)।
First Java Program: public static void main(String[] args) Breakdown — Exam FAQs
Q1: Why does Java not allow main to return an int like C or C++?
जावा में C या C++ की तरह main से int रिटर्न करने की अनुमति क्यों नहीं है?
[EN] Java separates program execution logic from OS process termination codes. Having main return void ensures clean JVM shutdown semantics (especially when non-daemon threads keep running after main finishes), while System.exit(int) explicitly triggers process exit codes.
[HI] जावा प्रोग्राम निष्पादन को OS प्रोसेस टर्मिनेशन कोड से अलग रखता है। main का void होना JVM शटडाउन को सुगम बनाता है (विशेषकर जब main समाप्त होने के बाद भी नॉन-डेमन थ्रेड्स चल रहे हों), जबकि एग्जिट कोड के लिए System.exit(int) प्रयुक्त होता है।
Q2: Can a Java program execute without any main method?
क्या कोई जावा प्रोग्राम बिना main मेथड के चल सकता है?
[EN] In JDK 6 and earlier, a static initializer block followed by System.exit(0) could execute before main was checked. Since JDK 7, the launcher checks for main(String[]) before loading/initializing the class, so standalone execution without main fails.
[HI] JDK 6 और उससे पहले static ब्लॉक के अंत में System.exit(0) लिखकर प्रोग्राम चलाया जा सकता था। परंतु JDK 7 से लॉन्चर क्लास इनिशियलाइज़ेशन से पहले ही main(String[]) की जांच करता है, इसलिए बिना main के स्टैंडअलोन निष्पादन विफल हो जाता है।
Q3: Why do we use String[] args for numeric command-line inputs?
संख्यात्मक कमांड-लाइन इनपुट के लिए भी String[] args का उपयोग क्यों किया जाता है?
[EN] String is universal and can represent any text, number, filename, or flag entered in the shell. Numeric strings inside args can easily be converted using Integer.parseInt(args[0]) or Double.parseDouble(args[1]).
[HI] String एक सार्वभौमिक प्रकार है जो शेल में टाइप किए गए किसी भी टेक्स्ट, संख्या, फ़ाइल नाम या फ़्लैग को धारण कर सकता है। संख्यात्मक मानों को आवश्यकतानुसार Integer.parseInt(args[0]) या Double.parseDouble(args[1]) से बदला जा सकता है।
Post a Comment
Post a Comment