पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 12 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
byte और short के literal को स्पष्ट रूप से बताने का तरीक़ा Java में क्या है?
What is the way to explicitly specify byte and short literals in Java?
Ab और s प्रत्यय सेWith the b and s suffixes
Bकोई सीधा तरीक़ा नहीं — range में आने पर compiler ख़ुद मान लेता हैThere is no direct way — the compiler takes it so when the value is within range
C0b और 0s उपसर्ग सेWith the 0b and 0s prefixes
D(byte) और (short) लिखना अनिवार्य हैWriting (byte) and (short) is compulsory
सही उत्तर / Answer: (B)
हल / Solution
पाठ कहता है — byte और short literal को स्पष्ट रूप से बताने का कोई सीधा तरीक़ा नहीं है; यह अप्रत्यक्ष रूप से होता है। जब byte variable को integral literal दिया जाता है और मान उसकी range में आता है तो compiler उसे अपने आप byte literal मान लेता है — «byte b = 127;» ठीक, «byte b = 128;» पर «Cannot convert int to byte»。
The text says — there is no direct way to specify byte and short literals explicitly; it happens indirectly. When an integral literal is assigned to a byte variable and the value falls within its range, the compiler treats it as a byte literal on its own — 'byte b = 127;' is fine, while 'byte b = 128;' gives 'Cannot convert int to byte'.
प्रश्न 2उत्तर + हल
Java में octal literal के बारे में क्या सही है?
What is true about octal literals in Java?
Aउपसर्ग 0 और अनुमत अंक 0-7Prefix 0 with digits 0-7 allowed
Bउपसर्ग 0o और अनुमत अंक 0-8Prefix 0o with digits 0-8 allowed
Cउपसर्ग 0x और अनुमत अंक 0-7Prefix 0x with digits 0-7 allowed
Dकोई उपसर्ग नहीं, अंक 0-7No prefix, digits 0-7
सही उत्तर / Answer: (A)
हल / Solution
पाठ के अनुसार Octal Form (Base 8) में अनुमत अंक 0-7 हैं और मान के आगे 0 लगाना होता है — «int x = 010;» वैध है और उसका मान 8 होता है। इसीलिए «int a = 0789;» पर error आती है: 8 और 9 octal में नहीं होते। «int a = 0777;» वैध है।
According to the text, the octal form (base 8) allows the digits 0-7 and the value must be prefixed with 0 — 'int x = 010;' is valid and its value is 8. This is why 'int a = 0789;' gives an error: 8 and 9 do not exist in octal. 'int a = 0777;' is valid.
प्रश्न 3उत्तर + हल
Java में float data type दशमलव बिंदु के बाद कितनी शुद्धता देता है?
What is the precision after decimal points offered by a float data type in Java?
A3 digits
B6 digits
C10 digits
D15 digits
सही उत्तर / Answer: (B)
हल / Solution
float बिंदु के बाद 5 से 6 अंक रख सकता है, सो दिए विकल्पों में 6 digits सही है; वह 4 byte का है और single precision का पालन करता है। double 14 से 15 अंक रखता है, 8 byte का है और double precision का — इसीलिए 15 digits वाला विकल्प double के लिए होता। 3 और 10 अंक किसी भी type की सीमा नहीं हैं।
A float can hold 5 to 6 digits after the point, so among the options given 6 digits is correct; it is 4 bytes and follows single precision. A double holds 14 to 15 digits, is 8 bytes and follows double precision — which is why the 15 digits option would belong to double. Neither 3 nor 10 digits is any type's limit.
प्रश्न 4उत्तर + हल
Java के किस संस्करण में hexadecimal floating point संख्याएँ आईं?
Which version of Java introduced hexadecimal floating point numbers?
AJDK 5
BJDK 6
CJDK 7
DJDK 8
सही उत्तर / Answer: (A)
हल / Solution
hexadecimal floating-point literal — जैसे 0x1.8p1, जिसमें p से घात लिखी जाती है — JDK 5 यानी Java 1.5 में आया। JDK 7 में binary literal (0b1010) और संख्या के बीच underscore आए, सो उसे यहाँ मिला देना आसान चूक है। छपे अध्याय के प्रश्न 14 की कुंजी JDK 7 बताती है, जो इस बिंदु पर ग़लत है।
The hexadecimal floating-point literal — such as 0x1.8p1, where p writes the exponent — arrived in JDK 5, that is Java 1.5. JDK 7 brought the binary literal (0b1010) and the underscore between digits, so confusing the two is an easy slip. The printed chapter's question 14 gives its key as JDK 7, which is wrong on this point.
प्रश्न 5उत्तर + हल
नीचे दिए गए विकल्पों में से boolean literal का सही उपयोग चुनिए।
Choose the correct usage of a boolean literal in the options below.
Aboolean b = false;
Bboolean b = 2<4;
Cif (true) { System.out.println("HELLO"); }
Dये सभीAll of the above
सही उत्तर / Answer: (D)
हल / Solution
तीनों सही हैं। पहले में false सीधा boolean literal है; दूसरे में 2<4 का परिणाम true आता है जो boolean ही है; तीसरे में true literal सीधे if की शर्त में रखा है, जो Java में पूरी तरह वैध है क्योंकि if को boolean चाहिए और true वही है। पाठ के अनुसार true, false और null — तीनों Java के reserved literal हैं।
All three are correct. In the first, false is a boolean literal directly; in the second, 2<4 evaluates to true, which is itself a boolean; in the third, the true literal is placed straight into the if condition, which is perfectly valid in Java because if requires a boolean and true is exactly that. By the text, true, false and null are Java's three reserved literals.
प्रश्न 6उत्तर + हल
नीचे दिए गए Java कथनों में से ग़लत चुनिए।
Choose the wrong Java code statement below.
Aboolean a = false;
Bboolean a = (5>6)||(4>3);
Cboolean a = 1;
Dboolean a = 4>3?true:false;
सही उत्तर / Answer: (C)
हल / Solution
boolean को सिर्फ़ true या false मिल सकते हैं — पाठ कहता है «boolean b=0;» पर incompatible types की error आती है, और 1 पर भी वही। Java में C की तरह 0 या 1 का अर्थ false या true नहीं होता। बाक़ी तीनों boolean ही देते हैं: false सीधा literal है, || का परिणाम boolean होता है, और ternary का परिणाम भी true या false ही आता है।
A boolean can take only true or false — the text says 'boolean b=0;' gives an incompatible types error, and 1 does the same. In Java, 0 or 1 do not mean false or true as they do in C. The other three all yield booleans: false is a literal directly, the result of || is a boolean, and a ternary's result is also just true or false.
प्रश्न 7उत्तर + हल
Java में Hexadecimal literal के सही उदाहरण चुनिए।
Choose the correct examples of hexadecimal literals in Java.
Along a = 0X987654321L;
Bint a = 0x76FE____23;
Cbyte b = 0X0__________F;
Dये सभीAll the above
सही उत्तर / Answer: (D)
हल / Solution
तीनों वैध हैं। hexadecimal में अंक 0-9 और A-F (किसी भी case में) चलते हैं, उपसर्ग 0x या 0X होता है। पहले में L प्रत्यय इसे long बनाता है। बाक़ी दोनों में underscore अंकों के बीच हैं — JDK 7 से यह अनुमत है, और लगातार कई underscore भी चलते हैं। «0X0F» का मान 15 है, जो byte की range में है।
All three are valid. In hexadecimal the digits 0-9 and A-F (in either case) are allowed, with the prefix 0x or 0X. In the first, the L suffix makes it a long. In the other two the underscores lie between digits — permitted since JDK 7, and several consecutive underscores work too. '0X0F' has the value 15, which is within byte's range.
प्रश्न 8उत्तर + हल
जावा में वह literal कौन-सा है जिससे यह जाँचा जा सकता है कि किसी भी प्रकार का object मौजूद (alive) है या नहीं?
What is the literal in Java that can be used to test whether an Object of any type is alive or not?
Aalive
Bliveof
Cnull
D0
सही उत्तर / Answer: (C)
हल / Solution
जावा में null एक विशेष literal है, जिसका अर्थ है कि reference किसी object की ओर इशारा नहीं करता। इसलिए if (obj != null) लिखकर जाँचते हैं कि object मौजूद है या नहीं। null को किसी भी reference प्रकार के वेरिएबल में रखा जा सकता है। alive और liveof जावा में कोई keyword या literal नहीं हैं। 0 एक int literal है, इसे object से नहीं मिलाया जा सकता। इसलिए सही उत्तर null है।
In Java, null is a special literal meaning that a reference does not point to any object. So we write if (obj != null) to check whether an object exists. null can be assigned to a variable of any reference type. alive and liveof are not keywords or literals in Java. 0 is an int literal and cannot be compared with an object reference. So the correct answer is null.
प्रश्न 9उत्तर + हल
जावा में back slash (\) से शुरू होने वाले character literals को क्या नाम दिया गया है?
What is the name given to character literals in Java that start with a Back Slash character?
ABack Slash Sequence
BSlash Sequence
CEscape Sequence
DExtended Sequence
सही उत्तर / Answer: (C)
हल / Solution
जावा में back slash से शुरू होने वाले विशेष char literal को escape sequence कहते हैं। ये ऐसे अक्षर दर्शाते हैं जिन्हें सीधे लिखना कठिन है। जैसे \n नई पंक्ति, \t tab, \' एकल उद्धरण, \" दोहरा उद्धरण और \\ ख़ुद back slash। back slash sequence, slash sequence या extended sequence जैसे नाम जावा में मान्य शब्द नहीं हैं। इसलिए सही उत्तर escape sequence है।
In Java, special char literals that begin with a back slash are called escape sequences. They represent characters that are hard to type directly. For example, \n is a new line, \t is a tab, \' is a single quote, \" is a double quote and \\ is the back slash itself. Names like back slash sequence, slash sequence or extended sequence are not Java terms. So the correct answer is escape sequence.
प्रश्न 10उत्तर + हल
जावा में binary literals दर्शाने के लिए किस उपसर्ग (prefix) का उपयोग किया जाता है?
What is the prefix used to represent Binary literals in Java?
Ab या Bb or B
B0b या 0B0b or 0B
CxB या xbxB or xb
Dob या oBob or oB
सही उत्तर / Answer: (B)
हल / Solution
जावा में binary literal लिखने के लिए संख्या के आगे 0b या 0B लगाते हैं, जैसे int a = 0b101; जिसका मान 5 है। सिर्फ़ b या B लगाने पर compiler उसे वेरिएबल का नाम समझेगा। xB या xb जैसा कोई prefix नहीं है; hexadecimal के लिए 0x लगता है। ob में पहला अक्षर o है, अंक 0 नहीं, इसलिए वह भी ग़लत है। सही उत्तर 0b या 0B है।
In Java, a binary literal starts with the prefix 0b or 0B, like int a = 0b101; whose value is 5. Writing only b or B would make the compiler treat it as a variable name. There is no prefix like xB or xb; hexadecimal uses 0x. In ob, the first character is the letter o, not the digit 0, so it is also wrong. Hence the correct answer is 0b or 0B.
आगे के 12 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
निम्नलिखित जावा कोड में क्या error होगी? byte b = 50; b = b * 50;
What will be the error in the following Java code? byte b = 50; b = b * 50;
Ab में मान 50 नहीं रखा जा सकताb cannot contain value 50
Bb में मान 100 नहीं रखा जा सकता, यह उसकी range से सीमित हैb cannot contain value 100, limited by its range
Cइस कोड में कोई error नहीं हैNo error in this code
D* operator ने b * 50 को int में बदल दिया है, जिसे casting के बिना byte में नहीं बदला जा सकता* operator has converted b * 50 into int, which can not be converted to byte without casting