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

Literals of Java — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
byte और short के literal को स्पष्ट रूप से बताने का तरीक़ा Java में क्या है?
What is the way to explicitly specify byte and short literals in Java?
  1. Ab और s प्रत्यय सेWith the b and s suffixes
  2. Bकोई सीधा तरीक़ा नहीं — range में आने पर compiler ख़ुद मान लेता हैThere is no direct way — the compiler takes it so when the value is within range
  3. C0b और 0s उपसर्ग सेWith the 0b and 0s prefixes
  4. 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?
  1. Aउपसर्ग 0 और अनुमत अंक 0-7Prefix 0 with digits 0-7 allowed
  2. Bउपसर्ग 0o और अनुमत अंक 0-8Prefix 0o with digits 0-8 allowed
  3. Cउपसर्ग 0x और अनुमत अंक 0-7Prefix 0x with digits 0-7 allowed
  4. 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?
  1. A3 digits
  2. B6 digits
  3. C10 digits
  4. 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?
  1. AJDK 5
  2. BJDK 6
  3. CJDK 7
  4. 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.
  1. Aboolean b = false;
  2. Bboolean b = 2<4;
  3. Cif (true) { System.out.println("HELLO"); }
  4. 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.
  1. Aboolean a = false;
  2. Bboolean a = (5>6)||(4>3);
  3. Cboolean a = 1;
  4. 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.
  1. Along a = 0X987654321L;
  2. Bint a = 0x76FE____23;
  3. Cbyte b = 0X0__________F;
  4. 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?
  1. Aalive
  2. Bliveof
  3. Cnull
  4. 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?
  1. ABack Slash Sequence
  2. BSlash Sequence
  3. CEscape Sequence
  4. 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?
  1. Ab या Bb or B
  2. B0b या 0B0b or 0B
  3. CxB या xbxB or xb
  4. 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 — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 15उत्तर app में
जावा में String literal को किसकी जोड़ी के भीतर लिखा जाता है?
A string literal in Java is surrounded by a pair of ____?
  1. Aमझले कोष्ठक (Braces)Braces
  2. Bएकल उद्धरण चिह्न (Single quotes)Single quotes
  3. Cदोहरे उद्धरण चिह्न (Double quotes)Double quotes
  4. Dविस्मयादिबोधक चिह्न (Exclamations)Exclamations
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
जावा में character literal को किसकी जोड़ी के भीतर लिखा जाता है?
A character literal in Java is enclosed within a pair of _____?
  1. Aवर्ग कोष्ठक (Square brackets)Square brackets
  2. Bदोहरे उद्धरण चिह्न (Double quotes)Double quotes
  3. Cएकल उद्धरण चिह्न (Single quotes)Single Quotes
  4. Dविस्मयादिबोधक चिह्न (Exclamations)Exclamations
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
जावा में int literal को long literal बनाने के लिए किस प्रत्यय (suffix) का उपयोग किया जाता है?
What is the suffix used to convert an int literal to long literals in Java?
  1. A0l या 0L0l or 0L
  2. Bl या Ll or L
  3. Ci या Ii or I
  4. D0x या 0X0x or 0X
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
f या F प्रत्यय के बिना लिखा गया floating point literal (वास्तविक संख्या) किस डेटा प्रकार का होता है?
A real number literal for floating point literal with a missing f or F suffix represents which data type?
  1. Adouble
  2. Blong
  3. Cfloat
  4. Dint
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
जावा में floating point संख्या दर्शाने के लिए किस प्रत्यय (suffix) का उपयोग किया जाता है?
What is the suffix used to represent a floating point number in Java?
  1. Ar या Rr or R
  2. Bf या Ff or F
  3. Cfl या FLfl or FL
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
यदि आप जावा में एक constant (स्थिर) वेरिएबल का मान बदलने का प्रयास करें तो क्या होगा?
What will happen if you try to change the value of a constant variable in Java?
  1. Acompilation error आएगी।It will raise a compilation error.
  2. Bनया मान पूरे प्रोग्राम में अपने आप update हो जाएगा।It will automatically update the new value throughout the program.
  3. Cruntime पर उपयोगकर्ता से नया मान डालने को कहा जाएगा।It will prompt the user to enter a new value during runtime.
  4. Dबिना किसी error के पुराना मान नए मान से बदल जाएगा।It will replace the old value with the new value without any error.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
निम्नलिखित जावा कोड में क्या error होगी?
byte b = 50;
b = b * 50;
What will be the error in the following Java code?
byte b = 50;
b = b * 50;
  1. Ab में मान 50 नहीं रखा जा सकताb cannot contain value 50
  2. Bb में मान 100 नहीं रखा जा सकता, यह उसकी range से सीमित हैb cannot contain value 100, limited by its range
  3. Cइस कोड में कोई error नहीं हैNo error in this code
  4. D* operator ने b * 50 को int में बदल दिया है, जिसे casting के बिना byte में नहीं बदला जा सकता* operator has converted b * 50 into int, which can not be converted to byte without casting
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Literals of Java के सभी 22 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

Java के दूसरे topics

सभी topics