FliQi Education App Download
प्रश्न-बैंक · Java

First Java Application — प्रश्न और उत्तर

Java · 24 जाँचे हुए (verified) प्रश्न

  • 24 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 14 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
main thread के मरने पर JVM क्या करता है?
What does the JVM do when the main thread dies?
  1. Aprogram दोबारा शुरू करता हैIt restarts the program
  2. Bदूसरा thread बनाता हैIt creates another thread
  3. Cकुछ नहीं, चलता रहता हैNothing, it keeps running
  4. Dअपनी सभी internal process बंद करके shut down mode में चला जाता हैIt shuts all its internal processes and goes into shut down mode

सही उत्तर / Answer: (D)

हल / Solution
पाठ का अंतिम चरण — जब main thread, main() method के end point पर पहुँच जाता है तो वह destroyed यानी dead अवस्था में चला जाता है, और जब main thread dead अवस्था में होता है तो JVM अपनी सभी internal process बंद कर देता है और shut down mode में चला जाता है। यही किसी Java application के चलने का अंत है।
The text's final step — when the main thread reaches the end point of the main() method it goes into a destroyed, that is dead, state, and when the main thread is in the dead state the JVM shuts down all its internal processes and goes into shut down mode. That is the end of a Java application's run.
प्रश्न 2उत्तर + हल
वर्तमान जगह की सभी Java file एक साथ compile करने का आदेश क्या है?
What is the command to compile all the Java files at the current location together?
  1. Ajavac all.java
  2. Bjavac -a
  3. Cjavac --every
  4. Djavac *.java

सही उत्तर / Answer: (D)

हल / Solution
पाठ चार रूप गिनाता है — javac *.java से वर्तमान जगह की सारी file; javac Employee*.java से वे जिनके आगे वह शब्द जुड़ा है; javac *address.java से वे जिनके पीछे जुड़ा है; और javac *Account*.java से वे जिनमें वह शब्द कहीं भी हो। इन्हें «-d» के साथ भी जोड़ा जा सकता है, जैसे «javac -d C:\abc *Account*.java»।
The text lists four forms — javac *.java for every file at the current location; javac Employee*.java for those with that word prefixed; javac *address.java for those with it postfixed; and javac *Account*.java for those containing that word anywhere in the name. These can be combined with '-d' as well, as in 'javac -d C:\abc *Account*.java'.
प्रश्न 3उत्तर + हल
main() method न मिलने पर JAVA7 क्या संदेश देता है?
What message does JAVA7 give when main() is not found?
  1. Ajava.lang.NoSuchMethodError:main
  2. Bjava.lang.NoClassDefFoundError
  3. CMain method not found in class FirstApp
  4. DCould not find or load main class FirstApp

सही उत्तर / Answer: (C)

हल / Solution
पाठ दोनों संस्करणों के संदेश अलग-अलग गिनाता है। main() न मिलने पर JAVA6 «java.lang.NoSuchMethodError:main» देता है और JAVA7 «Main method not found in class FirstApp, please define main method as: public static void main(String args[])»। बाक़ी दो संदेश तब आते हैं जब class ही न मिले, method न मिलने पर नहीं — यही दोनों ग़लतियों का फ़र्क़ है।
The text lists the messages of the two versions separately. When main() is not found, JAVA6 gives 'java.lang.NoSuchMethodError:main' and JAVA7 gives 'Main method not found in class FirstApp, please define main method as: public static void main(String args[])'. The other two messages appear when the class itself is not found rather than the method — and that is the difference between the two faults.
प्रश्न 4उत्तर + हल
main class का bytecode memory में कौन load करता है?
Who loads the main class bytecode into memory?
  1. Aoperating systemThe operating system
  2. BcompilerThe compiler
  3. CJVM के class loadersThe JVM's class loaders
  4. Dmain threadThe main thread

सही उत्तर / Answer: (C)

हल / Solution
पाठ के चरण 7 के अनुसार, आवश्यक .class file तीनों जगहों में से किसी एक पर मिल जाने पर JVM class loaders का उपयोग करके main class का bytecode memory में load करता है। उसके बाद ही वह main() method ढूँढ़ता है, और मिलने पर main thread नाम का thread बनाता है — सो main thread load के बाद आता है, पहले नहीं।
By the text's step 7, once the required .class file is found at one of those three locations the JVM loads the main class bytecode into memory using class loaders. Only after that does it search for the main() method, and on finding it creates a thread called the main thread — so the main thread comes after loading, not before.
प्रश्न 5उत्तर + हल
main class की .class file किसी और जगह पड़ी हो तो उसे JVM तक पहुँचाने के लिए क्या करना होगा?
If the main class's .class file lies elsewhere, what must be done to make it reach the JVM?
  1. Apath environment variable बदलनाChange the path environment variable
  2. Bclasspath environment variable सेट करनाSet the classpath environment variable
  3. Cfile का नाम बदलनाRename the file
  4. DJDK दोबारा स्थापित करनाReinstall the JDK

सही उत्तर / Answer: (B)

हल / Solution
पाठ का Note — यदि main class की .class file किसी दूसरी जगह उपलब्ध है तो उसे JVM तक पहुँचाने के लिए classpath environment variable सेट करना होगा, जैसे «D:\java7>set classpath=E:\XYZ;»। ध्यान रखिए path का काम अलग है — वह operating system को javac और java जैसे JDK के औज़ार ढूँढ़ने में मदद करता है।
The text's Note — if the main class's .class file is available at some other location, the classpath environment variable must be set to make it reach the JVM, as in 'D:\java7>set classpath=E:\XYZ;'. Note that path does a different job — it helps the operating system find the JDK's tools such as javac and java.
प्रश्न 6उत्तर + हल
«java» आदेश देने पर JVM main class को कहाँ-कहाँ ढूँढ़ता है?
On the 'java' command, where does the JVM search for the main class?
  1. Aसिर्फ़ वर्तमान जगह परOnly at the current location
  2. Bवर्तमान जगह, Java की predefined library, और classpath वाली जगहों परAt the current location, in Java's predefined library, and at the locations in classpath
  3. Cसिर्फ़ classpath परOnly in classpath
  4. Dसिर्फ़ path environment variable परOnly in the path environment variable

सही उत्तर / Answer: (B)

हल / Solution
पाठ के चरण 7 के अनुसार JVM main class को तीन जगह ढूँढ़ता है — वर्तमान स्थान पर, Java की predefined library में, और classpath environment variable से बताई गई जगहों पर। तीनों में न मिलने पर JAVA6 में «java.lang.NoClassDefFoundError» और JAVA7 में «Could not find or load main class» का संदेश आता है। ध्यान रहे path का काम अलग है — वह javac और java जैसे औज़ार ढूँढ़ने के लिए है।
By the text's step 7, the JVM searches for the main class in three places — at the current location, in Java's predefined library, and at the locations referred to by the classpath environment variable. If it is found in none of them, JAVA6 gives 'java.lang.NoClassDefFoundError' and JAVA7 gives 'Could not find or load main class'.
प्रश्न 7उत्तर + हल
नीचे की file को «javac -d c:\abc FirstApp.java» से compile करने पर कितनी .class file बनेंगी?

Package com.fliqi.core;

enum E { }

interface I { }

abstract class A { }

class B {

    class C {

    }

}

class FirstApp {

    public static void main(String[] args) {

    }

}
How many .class files are produced by compiling the file below with 'javac -d c:\abc FirstApp.java'?

Package com.fliqi.core;

enum E { }

interface I { }

abstract class A { }

class B {

    class C {

    }

}

class FirstApp {

    public static void main(String[] args) {

    }

}
  1. AछहSix
  2. BदोTwo
  3. CएकOne
  4. DतीनThree

सही उत्तर / Answer: (A)

हल / Solution
पाठ का Note कहता है कि बनने वाली .class file की संख्या class, abstract class, interface, enum और internal class की संख्या पर निर्भर है। यहाँ छह निकलते हैं — E.class, I.class, A.class, B.class, B$C.class और FirstApp.class। भीतर वाली class C का नाम B$C बनता है, और सब «c:\abc» में package के ढाँचे के अनुसार रखे जाते हैं।
The text's Note says the number of .class files produced depends on the count of classes, abstract classes, interfaces, enums and internal classes used in the file. Six come out here — E.class, I.class, A.class, B.class, B$C.class and FirstApp.class. The inner class C is named B$C, and all of them are placed in 'c:\abc' following the package structure.
प्रश्न 8उत्तर + हल
compile की गई .class file को किसी दूसरी जगह भेजने के लिए कौन-सा आदेश है?
Which command sends the generated .class files to another location?
  1. Ajavac -d target_location File_Name.java
  2. Bjavac -o target_location File_Name.java
  3. Cjava -d target_location File_Name.java
  4. Djavac File_Name.java -target

सही उत्तर / Answer: (A)

हल / Solution
पाठ का रूप यही है — javac -d target_location File_Name.java, जैसे «d:\java9>javac -d c:\abc FirstApp.java»। -d का काम यही है कि .class file उसी जगह न बनें जहाँ से compile किया गया, बल्कि बताई गई जगह पर जाएँ। और यदि file में package का कथन हो तो उसी नाम के अनुरूप directory का ढाँचा भी बन जाता है।
The text's form is just this — javac -d target_location File_Name.java, as in 'd:\java9>javac -d c:\abc FirstApp.java'. The job of -d is that the .class files are not made where the compile was run from but go to the stated location. And if the file carries a package statement, a directory structure matching that name is created as well.
प्रश्न 9उत्तर + हल
पाठ के अनुसार Java application बनाने के सात चरणों में पहला और अंतिम क्या हैं?
According to the text, what are the first and last of the seven steps to build a Java application?
  1. AJava program लिखना और उसे save करनाWriting the Java program and saving it
  2. BEclipse स्थापित करना और compile करनाInstalling Eclipse and compiling
  3. Cenvironment variable सेट करना और program लिखनाSetting the environment variable and writing the program
  4. DJava software स्थापित करना और Java application चलानाInstalling the Java software and executing the Java application

सही उत्तर / Answer: (D)

हल / Solution
पाठ के सात चरण क्रम से — 1. Install Java Software, 2. Set Environment Variable, 3. Install a Java Editor (Eclipse), 4. Write Java Program, 5. Save Java File, 6. Compile Java File, 7. Execute Java Application। सो पहला Java software स्थापित करना और अंतिम application चलाना है; program लिखना और save करना बीच के चरण हैं, पहला या अंतिम नहीं।
The text's seven steps in order — 1. Install Java Software, 2. Set Environment Variable, 3. Install a Java Editor (Eclipse), 4. Write Java Program, 5. Save Java File, 6. Compile Java File, 7. Execute Java Application. So the first is installing the Java software and the last is executing the application; writing and saving the program are middle steps, neither first nor last.
प्रश्न 10उत्तर + हल
पाठ के अनुसार Java editor के रूप में कौन-सा software स्थापित करने को कहा गया है?
According to the text, which software is to be installed as the Java editor?
  1. ANetBeans
  2. BIntelliJ IDEA
  3. CNotepad++
  4. DEclipse

सही उत्तर / Answer: (D)

हल / Solution
पाठ का तीसरा चरण है «Install a Java Editor (Eclipse)»। उसमें eclipse.org के download पन्ने से windows का .exe उतारा जाता है, उस पर दो बार click किया जाता है, और खुलने वाले installer में Eclipse IDE for Java Developers चुनकर Install दबाया जाता है; स्थापना में कुछ मिनट लगते हैं। बाक़ी तीनों नाम असली editor के हैं, पर इस पाठ के सात चरणों में उनका ज़िक्र कहीं नहीं आता।
The text's third step is 'Install a Java Editor (Eclipse)'. In it the windows .exe is downloaded from the eclipse.org downloads page, double-clicked, and in the installer window that appears Eclipse IDE for Java Developers is chosen and Install pressed; the installation takes a few minutes. The other three names belong to real editors, but this text's seven steps make no mention of any of them.
आगे के 14 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
Java संस्करण आसानी से एक से दूसरे में बदलने के लिए पाठ क्या सुझाता है?
What does the text suggest for switching easily from one Java version to another?
  1. Aहर बार JDK दोबारा स्थापित करनाReinstalling the JDK each time
  2. BEclipse बदलनाChanging Eclipse
  3. Cbatch file का उपयोगUsing a batch file
  4. DOperating System बदलनाChanging the operating system
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में
path environment variable में JAVA6, JAVA7 और JAVA8 — तीनों सेट हों तो command prompt पर कौन-सा संस्करण आएगा?
If JAVA6, JAVA7 and JAVA8 are all set in the path environment variable, which version appears at the command prompt?
  1. Aसबसे नया — JAVA8The newest — JAVA8
  2. Bसबसे पुराना हमेशाAlways the oldest
  3. Cजो path में पहले लिखा होWhichever appears first in the path
  4. Dहर बार कोई भी, तय नहींAny of them each time, it is not fixed
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
Java program लिखने के लिए किसकी predefined library का उपयोग होता है?
Whose predefined libraries are used for writing a Java program?
  1. AJVM कीThe JVM's
  2. BEclipse कीEclipse's
  3. CJAVA API (Application Programming Interface) कीThe JAVA API's (Application Programming Interface)
  4. DOperating System कीThe operating system's
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
Java file में कोई public element न हो तो उसे किस नाम से save किया जा सकता है?
If a Java file has no public element, by what name may it be saved?
  1. Aकिसी भी नाम से — पर main() वाली class के नाम से रखना उचित हैBy any name — though naming it after the class holding main() is advisable
  2. Bसिर्फ़ package के नाम सेOnly by the package's name
  3. Cसिर्फ़ Main.javaOnly Main.java
  4. Dउसे save ही नहीं किया जा सकताIt cannot be saved at all
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
नीचे का code किस file नाम से बिना error compile होगा?

public class A { }

class FirstApp {

    public static void main(String[] args){

        System.out.println("First Java Application");

    }

}
Under which file name will the code below compile without error?

public class A { }

class FirstApp {

    public static void main(String[] args){

        System.out.println("First Java Application");

    }

}
  1. AFirstApp.java
  2. BA.java
  3. Cabc.java
  4. Dकिसी भी नाम सेUnder any name
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
एक ही Java file में एक से अधिक public class रखी जा सकती हैं?
Can more than one public class be provided in a single Java file?
  1. Aहाँ, कितनी भीYes, any number
  2. Bनहीं — तब file को एक से अधिक नाम से save करना पड़ता, जो सम्भव नहींNo — the file would then have to be saved under more than one name, which is not possible
  3. Cहाँ, पर सिर्फ़ दोYes, but only two
  4. Dहाँ, यदि वे एक ही package में होंYes, if they are in the same package
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
Java file में public element हो तो उसे किस नाम से save करना चाहिए?
If a Java file has a public element, by what name must it be saved?
  1. Aउसी public element के नाम सेBy that public element's own name
  2. Bकिसी भी नाम सेBy any name
  3. Cसदा Main के नाम सेAlways as Main
  4. Dpackage के नाम सेBy the package's name
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
कौन सा सॉफ्टवेयर कंप्यूटर पर जावा प्रोग्राम चलाता है?
What software runs a Java program on a computer?
  1. AJRE (Java Runtime Environment)
  2. BJDK (Java development Kit)
  3. Cकमांड प्रॉम्प्टCommand Prompt
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
बाइट कोड किसका परिणाम है?
Byte code is the result of?
  1. AJava फ़ाइल को कम्पाइल करने काCompiling a Java file
  2. BClass फ़ाइल को कम्पाइल करने काCompiling a Class file
  3. CJava फ़ाइल को इंटरप्रेट करने काInterpreting a Java File
  4. DClass फ़ाइल को इंटरप्रेट करने काInterpreting a Class file
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
जावा सोर्स फ़ाइलों के बारे में एक सही कथन चुनें।
Choose a correct statement about Java source files.
  1. AJava फ़ाइलें इंसान द्वारा पढ़ी जा सकती हैंJava files are human readable
  2. BJava फ़ाइलों में Methods और Variables वाली Classes होती हैंJava files contain Classes with Methods and Variables
  3. CImport statements लाइब्रेरी की Classes को हमारी class में import करते हैंImport statements import library Classes into our class
  4. Dउपरोक्त सभीAll the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
First Java Application के सभी 24 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

Java के दूसरे topics

सभी topics