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

Operator — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
जावा में लॉजिकल ऑपरेटर (logical operator) कौन से हैं?
Which of the following are the logical operators in Java?
  1. A&&
  2. B||
  3. CAll of the above
  4. DNone of the above

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

हल / Solution
जावा के लॉजिकल (logical) ऑपरेटर पहले और दूसरे विकल्प, दोनों हैं। पहला लॉजिकल AND है — दोनों शर्तें सही हों तभी true देता है। दूसरा लॉजिकल OR है — कोई एक शर्त सही होने पर ही true मिल जाता है। दोनों शॉर्ट-सर्किट (short-circuit) तरीक़े से चलते हैं, यानी नतीजा पहले हिस्से से तय हो जाए तो दूसरा हिस्सा जाँचा ही नहीं जाता। चूँकि दोनों लॉजिकल हैं, इसलिए तीसरा विकल्प सही है।
Both the first and the second option are logical operators in Java. The first one is logical AND and returns true only when both conditions are true. The second is logical OR and returns true as soon as any one condition is true. Both work in a short-circuit way, so the second condition is not even checked when the first already decides the result. Since both belong to the group, the third option is correct.
प्रश्न 2उत्तर + हल
जावा में decrement करने के लिए निम्नलिखित में से किस ऑपरेटर का उपयोग किया जाता है?
Which of the following operators is used to perform decrement in Java?
  1. A--
  2. B+
  3. C*
  4. D&

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

हल / Solution
किसी चर (variable) का मान एक घटाने के लिए जावा में डिक्रीमेंट (decrement) ऑपरेटर लगता है, जो दो ऋण-चिह्न से बनता है। x-- या --x लिखने पर x एक कम हो जाता है। दूसरा विकल्प जोड़ का ऑपरेटर है और तीसरा गुणा का। चौथा विकल्प बिटवाइज़ AND है, जो दो संख्याओं के बिट मिलाता है। इनमें से कोई मान घटाता नहीं। ध्यान रखिए, डिक्रीमेंट एक यूनरी (unary) ऑपरेटर है।
Java uses the decrement operator, written as two minus signs, to lower the value of a variable by one. Writing x-- or --x makes x smaller by one. The second option adds and the third multiplies. The fourth option is bitwise AND, which combines the bits of two numbers. None of them reduces a value, so the first option is correct. Note also that decrement is a unary operator, as it works on a single variable.
प्रश्न 3उत्तर + हल
निम्नलिखित कोड का आउटपुट क्या होगा?
int a = 5;
int b = 7;
System.out.println((a > b) ? "a is greater than b" : "a is less than or equal to b");
What is the output of the following code snippet?
int a = 5;
int b = 7;
System.out.println((a > b) ? "a is greater than b" : "a is less than or equal to b");
  1. Aa is greater than b
  2. Ba is less than or equal to b
  3. CCompilation error
  4. DRuntime error

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

हल / Solution
यहाँ a का मान 5 है और b का 7, इसलिए शर्त (a > b) झूठी हो जाती है। टर्नरी ऑपरेटर (ternary operator) शर्त झूठी होने पर कोलन के बाद वाला मान देता है, इसलिए दूसरा विकल्प छपेगा। पहला विकल्प तभी आता जब a बड़ा होता। कोड में वाक्य-रचना की कोई ग़लती नहीं है, इसलिए compilation error नहीं आती, और चलते समय कोई अपवाद नहीं उठता, इसलिए runtime error भी ग़लत है।
Here a holds 5 and b holds 7, so the condition (a > b) is false. A ternary operator returns the value written after the colon when the condition is false, so the second string is printed. The first option would appear only if a were the larger number. The code has no syntax mistake, so there is no compilation error, and nothing is thrown while it runs, so a runtime error is wrong too.
प्रश्न 4उत्तर + हल
जावा में bitwise XOR करने के लिए निम्नलिखित में से किस ऑपरेटर का उपयोग किया जाता है?
Which of the following operators is used to perform bitwise XOR in Java?
  1. A^
  2. B|
  3. C&
  4. D~

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

हल / Solution
बिटवाइज़ XOR (exclusive OR) के लिए जावा में कैरट चिह्न लगता है। यह दोनों संख्याओं के बिट मिलाकर वहीं 1 देता है जहाँ बिट अलग-अलग हों, और बराबर बिट पर 0 देता है। दूसरा विकल्प बिटवाइज़ OR है, जो कोई भी एक बिट 1 होने पर 1 देता है। तीसरा बिटवाइज़ AND है, जिसमें दोनों बिट 1 होने ज़रूरी हैं। चौथा बिटवाइज़ NOT है और हर बिट उलट देता है।
Java uses the caret sign for bitwise XOR, that is exclusive OR. It compares the bits of two numbers and gives 1 only where the bits differ, and 0 where they are the same. The second option is bitwise OR, which gives 1 if either bit is 1. The third is bitwise AND, which needs both bits to be 1. The fourth is bitwise NOT and flips every single bit.
प्रश्न 5उत्तर + हल
निम्नलिखित में से कौन जावा में यूनरी लॉजिकल ऑपरेटर (unary logical operator) है?
Which of the following is a unary logical operator in Java?
  1. A!
  2. B&
  3. C|
  4. D^

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

हल / Solution
यूनरी (unary) ऑपरेटर उसे कहते हैं जो सिर्फ़ एक मान पर लगता है। लॉजिकल NOT यानी विस्मयादिबोधक चिह्न ठीक यही करता है — true को false और false को true कर देता है। दूसरा विकल्प बिटवाइज़ AND है, तीसरा बिटवाइज़ OR और चौथा बिटवाइज़ XOR। इन तीनों को दो-दो मान चाहिए, इसलिए वे बाइनरी (binary) ऑपरेटर हैं। इस सूची में अकेला यूनरी लॉजिकल ऑपरेटर पहला ही है।
A unary operator works on just one value. The logical NOT operator does exactly that: it turns true into false and false into true. The other three are bitwise AND, bitwise OR and bitwise XOR, and each of them needs two values, so they are binary operators. That makes the exclamation mark the only unary logical operator in the given list, so the first option is the right answer here.
प्रश्न 6उत्तर + हल
निम्नलिखित में से कौन जावा में कंडीशनल ऑपरेटर (conditional operator) है?
Which of the following is a conditional operator in Java?
  1. A=
  2. B*
  3. C+
  4. D?

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

हल / Solution
जावा का कंडीशनल या टर्नरी ऑपरेटर (conditional / ternary operator) प्रश्नचिह्न और कोलन से बनता है, इसलिए विकल्पों में प्रश्नचिह्न ही सही है। इसका रूप है — शर्त ? मान एक : मान दो। शर्त सही हुई तो पहला मान मिलता है, वरना दूसरा। बराबर का चिह्न असाइनमेंट ऑपरेटर है, जो सिर्फ़ मान रखता है। गुणा और जोड़ के चिह्न अंकगणितीय ऑपरेटर हैं। ये तीनों कोई शर्त जाँचते ही नहीं।
Java's conditional or ternary operator is made of a question mark and a colon, so the question mark is the right choice. Its form is: condition ? value one : value two. If the condition is true the first value is taken, otherwise the second. The equals sign is the assignment operator, which only stores a value. The star and the plus sign are arithmetic operators. None of those three tests a condition, so option four is correct.
प्रश्न 7उत्तर + हल
जावा में left shift करने के लिए निम्नलिखित में से किस ऑपरेटर का उपयोग किया जाता है?
Which of the following operators is used to perform left shift in Java?
  1. A<<
  2. B>>
  3. C&
  4. D|

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

हल / Solution
जावा में बिट बाईं ओर खिसकाने के लिए लेफ़्ट शिफ़्ट (left shift) ऑपरेटर दो से कम वाले चिह्न से बनता है। x << 1 करने पर हर बिट एक जगह बाईं ओर जाता है, यानी मान दोगुना हो जाता है। दूसरा विकल्प राइट शिफ़्ट (right shift) है, जो बिट दाईं ओर ले जाता है। तीसरा विकल्प बिटवाइज़ AND है और चौथा बिटवाइज़ OR — ये दोनों दो संख्याओं के बिट मिलाते हैं, खिसकाते नहीं।
In Java the left shift operator moves the bits of a number towards the left. Writing x << 1 pushes every bit one place left, which doubles the value. The second option is the right shift operator and moves bits the other way. The third option is bitwise AND and the fourth is bitwise OR; both of them combine the bits of two numbers instead of shifting them. So the first option is correct.
प्रश्न 8उत्तर + हल
निम्नलिखित कोड snippet का आउटपुट क्या है?
int a = 5;
int b = 2;
int c = a / b;
System.out.println(c);
What is the output of the following code snippet?
int a = 5;
int b = 2;
int c = a / b;
System.out.println(c);
  1. A2
  2. B2.5
  3. C3
  4. Dकंपाइलेशन एररCompilation error

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

हल / Solution
दोनों operand int हैं, इसलिए जावा पूर्णांक भाग करता है और दशमलव वाला हिस्सा फेंक देता है। 5 में 2 का भाग देने पर 2.5 बनता है, पर int में सिर्फ़ 2 बचता है, इसलिए c का मान 2 छपता है। विकल्प 2 तब मिलता जब कोई operand double होता या cast लगाया जाता। विकल्प 3 ग़लत है क्योंकि यहाँ ऊपर की तरफ़ गोल नहीं किया जाता। कोड पूरी तरह वैध है, इसलिए विकल्प 4 भी ठीक नहीं।
Both operands are int, so Java performs integer division and throws the fractional part away. Dividing 5 by 2 gives 2.5, but only 2 survives in an int, so the value printed for c is 2. Option 2 is what you would get if one operand were a double or a cast were applied. Option 3 is wrong because nothing is rounded upward here. The code is perfectly valid, so option 4 fails too.
प्रश्न 9उत्तर + हल
जावा में logical OR एक्सीक्यूट करने के लिए निम्नलिखित में से किस ऑपरेटर का उपयोग किया जाता है?
Which of the following operators is used to perform logical OR in Java?
  1. A&
  2. B&&
  3. C||
  4. D^

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

हल / Solution
दो पाइप वाला चिह्न लॉजिकल OR है। इसे दो boolean शर्तें चाहिए और इनमें से कोई एक भी सही हो तो नतीजा true आता है। पहली शर्त सही मिल जाने पर यह दूसरी जाँचता ही नहीं, इसे short-circuit व्यवहार कहते हैं। दो ऐंपरसैंड वाला रूप उलटा काम करता है, यानी दोनों शर्तें माँगता है। एक ऐंपरसैंड और ^ चिह्न bitwise परिवार के हैं, इसलिए वे यहाँ सही उत्तर नहीं हैं।
The double pipe is the logical OR. It takes two boolean conditions, and if even one of them holds, the result is true. Once the first condition turns out true it does not test the second at all, which is called short-circuit behaviour. The double ampersand does the opposite job, demanding both conditions. The single ampersand and the ^ sign belong to the bitwise family, so they are not the answer here.
प्रश्न 10उत्तर + हल
जावा में Bitwise OR निष्पादित करने के लिए निम्नलिखित में से किस ऑपरेटर का उपयोग किया जाता है?
Which of the following operators is used to perform Bitwise OR in Java?
  1. A|
  2. B^
  3. C&
  4. D||

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

हल / Solution
एक पाइप वाला चिह्न bitwise OR करता है। दोनों संख्याओं के बिट जोड़े बनाकर देखे जाते हैं और नतीजे में 0 वहीं आता है जहाँ दोनों बिट 0 हों, बाक़ी हर जगह 1। दो पाइप वाला रूप लॉजिकल OR है, जो पूरी शर्तों पर चलता है और पहली शर्त सही मिलते ही दूसरी छोड़ देता है। ^ चिह्न XOR करता है, जहाँ दोनों बिट एक जैसे होने पर 0 आता है, और & चिह्न AND का है।
The single pipe performs bitwise OR. The bits of the two numbers are paired up, and the result carries a 0 only where both bits are 0, with a 1 everywhere else. The double pipe is the logical OR, which works on whole conditions and skips the second one as soon as the first is true. The ^ sign performs XOR, where matching bits give 0, and the & sign belongs to AND.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 18उत्तर app में
new ऑपरेटर क्या है?
What is the new operator?
  1. Aint और char जैसे primitive variable के लिए मेमोरी देता हैAllocates memory for primitive variables like int and char
  2. Bobject या array के लिए मेमोरी देता है और उसका reference लौटाता हैAllocates memory for an object or array and returns a reference to it
  3. Cobject बनने पर return type की तरह काम आता हैUsed as return type when an object is created
  4. Dप्रोग्राम में कोई भी नई चीज़ घोषित करने के लिएUsed to declare any new thing in a program
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
एक जावा टर्नरी ऑपरेटर की प्रायोरिटी ____ से कम होती है।
A Java Ternary operator has priority less than ____.
  1. Aरिलेशनल ऑपरेटरRelational operator
  2. Bअर्थमेटिक ऑपरेटरArithmetic operator
  3. Cलॉजिकल और बिटवाइज़ ऑपरेटरLogical and bitwise operator
  4. Dउपरोक्त सभीAll
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
सत्य या असत्य बताएँ — TRUE एक्सप्रेशन वाला भाग ? के बाद और : (कोलन) चिह्न के पहले आता है।
State TRUE or FALSE. The TRUE expression part comes first, after the ? (question mark) symbol and before the : (colon) symbol.
  1. Aअसत्य (FALSE)FALSE
  2. Bसत्य (TRUE)TRUE
  3. Cकुछ नहीं कहा जा सकताNothing can be said
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
जावा टर्नरी ऑपरेटर की कंडीशन का इवैल्यूएशन ____ पर होना चाहिए।
The condition of the Java ternary operator should evaluate to ____
  1. A1 या 01 or 0
  2. Btrue या falsetrue or false
  3. CTRUE या FALSETRUE or FALSE
  4. Dइनमें से कोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
जावा टर्नरी ऑपरेटर को कभी-कभी ____ कहा जाता है।
Java ternary operator is sometimes called ____.
  1. Aरिलेशनल ऑपरेटरRelational operator
  2. Bकंडीशनल ऑपरेटरConditional operator
  3. Cलॉजिकल ऑपरेटरLogical operator
  4. Dइनमें से कोई नहींNone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
जावा में प्रश्न चिह्न-कोलन (? :) ऑपरेटर का दूसरा नाम क्या है?
What is the other name for a question mark - colon (? :) operator in java?
  1. Aविशेष रिलेशनल ऑपरेटरSpecial Relational operator
  2. Bविशेष लॉजिकल ऑपरेटरSpecial Logical operator
  3. Cटर्नरी ऑपरेटरTernary operator
  4. Dइनमें से कोई नहींnone
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
जावा में ऑटोमैटिक प्रकार के कन्वर्जन के लिए इनमें से कौन सी आवश्यक कंडीशन है?
Which of these is necessary condition for automatic type conversion in Java?
  1. Aलक्ष्य प्रकार स्रोत प्रकार से छोटा होThe destination type is smaller than source type
  2. Bलक्ष्य प्रकार स्रोत प्रकार से बड़ा होThe destination type is larger than source type
  3. Cलक्ष्य प्रकार स्रोत से बड़ा या छोटा, कुछ भी हो सकता हैThe destination type can be larger or smaller than source type
  4. Dइनमें से कोई नहींNone of the mentioned
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 26उत्तर app में
यदि किसी एक्सप्रेशन में एक variable या operand long प्रकार का है, तो सभी ऑपरेंड को किस डेटा प्रकार में प्रमोट किया जाता है?
If a variable or operand in an expression is type long, then all the operands are type promoted to which data type?
  1. Aint
  2. Blong
  3. Cfloat
  4. Ddouble
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
यदि दोनों इनपुट/ऑपरेंड 1 हैं तो बिटवाइज़ AND (&) ऑपरेशन का आउटपुट क्या है?
What is the output of a Bitwise AND (&) operation if both the inputs / operands are 1s?
  1. A0
  2. B1
  3. C0 या 1 दोनों0 or 1 both
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Operator के सभी 55 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

Programmer Java के दूसरे topics

सभी topics