पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 11 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
«char ch2=65536;» पर क्या होगा?
What happens with 'char ch2=65536;'?
Aकोई error नहींNo error
Bवह ऋणात्मक मान बन जाएगाIt becomes a negative value
C65536 को 0 मान लिया जाएगा65536 is taken as 0
Dcompile-time error — यह char की range से बाहर हैA compile-time error — it is outside char's range
सही उत्तर / Answer: (D)
हल / Solution
char का आकार 2 byte है और उसकी range 0 से 65535 तक है, इसलिए 65536 उससे एक ऊपर चला जाता है और पाठ के अनुसार «possible loss of precision» वाली compile-time error मिलती है। उसी के साथ «char ch1=97;» वैध है, क्योंकि 97 range के भीतर है और char को संख्या से भी भरा जा सकता है — वह Unicode का वही अक्षर उठा लेता है।
A char is 2 bytes and its range runs from 0 to 65535, so 65536 goes one past it and, per the text, gives the 'possible loss of precision' compile-time error. Alongside it 'char ch1=97;' is valid, because 97 lies within the range and a char may be filled from a number too — it picks up that very Unicode character.
प्रश्न 2उत्तर + हल
signed data type में most significant bit का क्या काम है?
In a signed data type, what is the role of the most significant bit?
Aवह मान को दुगुना करता हैIt doubles the value
Bवह आकार बताता हैIt states the size
Cवह सदा 1 रहता हैIt always stays 1
Dवह sign bit है — 0 का अर्थ +ve और 1 का अर्थ -veIt is the sign bit — 0 means +ve and 1 means -ve
सही उत्तर / Answer: (D)
हल / Solution
पाठ कहता है — most significant bit sign bit के रूप में काम करता है, «0» का अर्थ +ve और «1» का अर्थ -ve। धनात्मक संख्याएँ सीधे memory में रखी जाती हैं, जबकि ऋणात्मक संख्याएँ 2's complement रूप में। boolean और char को छोड़कर बाक़ी सब signed हैं, और इसीलिए byte की range शून्य से 255 नहीं बल्कि -128 से 127 बनती है।
The text says — the most significant bit acts as the sign bit, where '0' means +ve and '1' means -ve. Positive numbers are represented directly in memory, while negative numbers are represented in 2's complement form. Apart from boolean and char all the rest are signed, and that is why byte's range comes out as -128 to 127 rather than zero to 255.
प्रश्न 3उत्तर + हल
Non-primitive या user defined data type में क्या-क्या आता है?
What falls under non-primitive or user defined data types?
Aसिर्फ़ classOnly classes
Bसिर्फ़ arrayOnly arrays
Cसिर्फ़ interfaceOnly interfaces
Dसभी class, abstract class, interface और arrayAll classes, abstract classes, interfaces and arrays
सही उत्तर / Answer: (D)
हल / Solution
पाठ के अनुसार Non-Primitive, User Defined या Secondary data type में सभी class, सभी abstract class, सभी interface और सभी array आते हैं, और इनके लिए कोई निश्चित memory allocation नहीं होता। यही उन्हें 8 primitive type से अलग करता है, जिनका आकार तय है — byte एक, short दो, int चार, long आठ, float चार, double आठ और char दो byte का।
According to the text, non-primitive, user defined or secondary data types include all classes, all abstract classes, all interfaces and all arrays, and for these there is no fixed memory allocation. That is what sets them apart from the 8 primitive types, whose sizes are fixed — byte one, short two, int four, long eight, float four, double eight and char two bytes.
प्रश्न 4उत्तर + हल
file या network से streams के रूप में data सँभालने के लिए सबसे उपयुक्त data type कौन है?
Which data type is best suited for handling data as streams from a file or network?
Aint
Blong
Cchar
Dbyte
सही उत्तर / Answer: (D)
हल / Solution
पाठ कहता है — यदि file या network से streams के संदर्भ में data handle कर रहे हैं तो byte data type सबसे उपयुक्त है। कारण सीधा है: stream एक-एक byte में बहती है, और byte उतनी ही जगह लेता है, न कम न ज़्यादा। int या long लेने पर हर अक्षर के लिए चार या आठ गुना memory बेकार जाती, और char का रूप तो Unicode का है।
The text says — if data is being handled in the context of streams from a file or network, the byte data type is best suited. The reason is plain: a stream flows byte by byte, and a byte occupies exactly that much space, no more and no less. Taking an int or long would waste four or eight times the memory per character, and char's form is Unicode's.
प्रश्न 5उत्तर + हल
सभी integral constant का default data type क्या होता है?
What is the default data type of all integral constants?
Abyte
Bshort
Clong
DInteger
सही उत्तर / Answer: (D)
हल / Solution
पाठ का Note कहता है — «सभी integral constants का default data type Integer है»। इसीलिए किसी बड़े मान को सीधे long में डालते समय सावधानी चाहिए, और छोटे type में डालने पर «possible loss of precision» आ सकती है। यही कारण है कि byte या short पर गणित करते ही परिणाम int बन जाता है और उसे वापस उसी type में डालने के लिए casting चाहिए।
The text's Note says — 'the default data type of all integral constants is Integer'. This is why care is needed when putting a large value straight into a long, and why putting one into a smaller type can give 'possible loss of precision'. It is also the reason arithmetic on a byte or short makes the result an int, needing a cast to put it back into that type.
प्रश्न 6उत्तर + हल
किसी data type का min और max मान जानने के लिए Java कौन-से दो constant देता है?
Which two constants does Java provide to find a data type's minimum and maximum values?
ALOW_VALUE और HIGH_VALUELOW_VALUE and HIGH_VALUE
BFIRST और LASTFIRST and LAST
CMIN_VALUE और MAX_VALUEMIN_VALUE and MAX_VALUE
DSTART और ENDSTART and END
सही उत्तर / Answer: (C)
हल / Solution
पाठ के अनुसार हर data type का «min value» और «max value» जानने के लिए Java सभी wrapper class में दो constant variable देता है — MIN_VALUE और MAX_VALUE। जैसे Byte.MIN_VALUE और Byte.MAX_VALUE। ध्यान दें, Boolean पर ये नहीं होते — पाठ के उदाहरण में वह पंक्ति जान-बूझकर टिप्पणी कर दी गई है, क्योंकि boolean की कोई range ही नहीं होती।
According to the text, to find each data type's 'min value' and 'max value' Java provides two constant variables in every wrapper class — MIN_VALUE and MAX_VALUE. For example Byte.MIN_VALUE and Byte.MAX_VALUE. Note that Boolean does not have them — in the text's example that line is deliberately commented out, because boolean has no range at all.
Cfloat 5-6 दशमलव स्थान और single precision; double 14-15 और double precisionfloat gives 5-6 decimal places with single precision; double 14-15 with double precision
Dदोनों double precision का पालन करते हैंBoth follow double precision
सही उत्तर / Answer: (C)
हल / Solution
पाठ की तुलना-तालिका — float बिंदु के बाद 5 से 6 अंक रख सकता है, 4 bytes का है और single precision का पालन करता है; double 14 से 15 अंक रखता है, 8 bytes का है और double precision का। precision का अर्थ यहाँ शुद्धता है। इसीलिए अधिक सटीकता चाहिए तो double चुना जाता है, और जगह बचानी हो तो float।
The text's comparison table — float can hold 5 to 6 digits after the point, is 4 bytes and follows single precision; double holds 14 to 15 digits, is 8 bytes and follows double precision. Precision here indicates accuracy. This is why double is chosen when more accuracy is needed, and float when space is to be saved instead.
प्रश्न 8उत्तर + हल
boolean variable की इनमें से कौन-सी घोषणा वैध है?
Which of these boolean declarations is valid?
Aboolean b="true";
Bboolean b=0;
Cboolean b=true;
Dboolean b=null;
सही उत्तर / Answer: (C)
हल / Solution
boolean को सिर्फ़ true या false मिल सकते हैं, और वे छोटे अक्षरों में ही लिखे जाते हैं। पाठ के उदाहरण बताते हैं: «boolean b="True";» और «boolean b=0;» पर incompatible types की error आती है, और बड़े T वाले «boolean b=True;» पर cannot find symbol — क्योंकि True नाम की कोई चीज़ ही नहीं। null भी नहीं चलता, वह object reference का default है। Java में 0 का अर्थ false नहीं होता, जैसा C में होता है।
A boolean can take only true or false, and they are written in lowercase alone. The text's examples show that 'boolean b="True";' and 'boolean b=0;' give an incompatible types error, and 'boolean b=True;' with a capital T gives cannot find symbol — because there is no such thing as True. null does not work either; it is the default of an object reference. In Java 0 does not mean false, as it does in C.
प्रश्न 9उत्तर + हल
Java में सबसे कम उपयोग किया जाने वाला और सबसे अधिक उपयोग किया जाने वाला data type क्रमशः कौन हैं?
Which are the least used and the most used data types in Java respectively?
Abyte और longbyte and long
Bshort और intshort and int
Cchar और doublechar and double
Dboolean और floatboolean and float
सही उत्तर / Answer: (B)
हल / Solution
पाठ सीधे लिखता है — «Java में सबसे कम उपयोग किया जाने वाला data type short है» और «यह (int) Java में सबसे अधिक उपयोग किया जाने वाला data type है»। short 8086 जैसे 16-bit processor के लिए उपयुक्त था, पर वे processor पुराने पड़ गए इसलिए short भी out हो गया। int का आकार 4 byte है और वही आम ज़रूरत पूरी करता है।
The text states it directly — 'the least used data type in Java is short' and 'this (int) is the most used data type in Java'. short suited 16-bit processors such as the 8086, but those processors became obsolete and so short went out with them. int is 4 bytes in size and meets the ordinary need well.
प्रश्न 10उत्तर + हल
integral data type की range निकालने का सूत्र क्या है, जहाँ n bit की संख्या है?
What is the formula for the range of an integral data type, where n is the number of bits?
A-2ⁿ से 2ⁿ-2ⁿ to 2ⁿ
B-2ⁿ⁻¹ से 2ⁿ⁻¹-1-2ⁿ⁻¹ to 2ⁿ⁻¹-1
C0 से 2ⁿ-10 to 2ⁿ-1
D-2ⁿ⁻¹-1 से 2ⁿ⁻¹-2ⁿ⁻¹-1 to 2ⁿ⁻¹
सही उत्तर / Answer: (B)
हल / Solution
पाठ का सूत्र है: ऋण दो की घात n-1, से लेकर दो की घात n-1 में से एक कम। byte पर लगाइए तो n आठ है और सीमा -128 से 127 बनती है; short पर -32768 से 32767। इसी से «byte b=130;» अवैध और «byte b=125;» वैध ठहरता है। पाठ का Note याद रखिए — यह सूत्र सिर्फ़ integral type पर लागू है, float और double पर नहीं।
The text's formula is: minus two to the power n-1, up to two to the power n-1 minus one. Apply it to byte, where n is eight, and the range comes out as -128 to 127; for short it gives -32768 to 32767. This is what makes 'byte b=130;' invalid and 'byte b=125;' valid. Remember the text's Note — this formula applies only to integral types and not to float or double.
आगे के 11 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
Java को strongly typed language क्यों माना जाता है?
Why is Java regarded as a strongly typed language?
Aहर variable और expression का type तय होता है और हर assignment की type-संगति compiler जाँचता हैEvery variable and expression has a type and the compiler checks each assignment for type compatibility
Bक्योंकि इसमें pointer नहीं होतेBecause it has no pointers
Cक्योंकि यह Unicode पर आधारित हैBecause it is Unicode based
Dक्योंकि इसमें 8 primitive type हैंBecause it has 8 primitive types