पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 14 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
main thread के मरने पर JVM क्या करता है?
What does the JVM do when the main thread dies?
Aprogram दोबारा शुरू करता हैIt restarts the program
Bदूसरा thread बनाता हैIt creates another thread
Cकुछ नहीं, चलता रहता हैNothing, it keeps running
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?
Ajavac all.java
Bjavac -a
Cjavac --every
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?
Ajava.lang.NoSuchMethodError:main
Bjava.lang.NoClassDefFoundError
CMain method not found in class FirstApp
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?
Aoperating systemThe operating system
BcompilerThe compiler
CJVM के class loadersThe JVM's class loaders
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?
Apath environment variable बदलनाChange the path environment variable
Bclasspath environment variable सेट करनाSet the classpath environment variable
Cfile का नाम बदलनाRename the file
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?
Aसिर्फ़ वर्तमान जगह परOnly at the current location
Bवर्तमान जगह, Java की predefined library, और classpath वाली जगहों परAt the current location, in Java's predefined library, and at the locations in classpath
Cसिर्फ़ classpath परOnly in classpath
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) {
}
}
AछहSix
BदोTwo
CएकOne
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?
Ajavac -d target_location File_Name.java
Bjavac -o target_location File_Name.java
Cjava -d target_location File_Name.java
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?
AJava program लिखना और उसे save करनाWriting the Java program and saving it
BEclipse स्थापित करना और compile करनाInstalling Eclipse and compiling
Cenvironment variable सेट करना और program लिखनाSetting the environment variable and writing the program
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?
ANetBeans
BIntelliJ IDEA
CNotepad++
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 — अभ्यास, हल और आपकी प्रगति
एक ही Java file में एक से अधिक public class रखी जा सकती हैं?
Can more than one public class be provided in a single Java file?
Aहाँ, कितनी भीYes, any number
Bनहीं — तब file को एक से अधिक नाम से save करना पड़ता, जो सम्भव नहींNo — the file would then have to be saved under more than one name, which is not possible
Cहाँ, पर सिर्फ़ दोYes, but only two
Dहाँ, यदि वे एक ही package में होंYes, if they are in the same package