पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
जावा में लॉजिकल ऑपरेटर (logical operator) कौन से हैं?
Which of the following are the logical operators in Java?
A&&
B||
CAll of the above
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?
A--
B+
C*
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");
Aa is greater than b
Ba is less than or equal to b
CCompilation error
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?
A^
B|
C&
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?
A!
B&
C|
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?
A=
B*
C+
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?
A<<
B>>
C&
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);
A2
B2.5
C3
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?
A&
B&&
C||
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?
A|
B^
C&
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 — अभ्यास, हल और आपकी प्रगति