Practice high-yield Programming & Software Development MCQs on Operators In Ruby — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used for addition in Ruby?
Correct Answer: Option A — +
Detailed Academic Explanation:
+ is the correct answer to “Which operator is used for addition in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the += operator do in Ruby?
Correct Answer: Option D — Addition
Detailed Academic Explanation:
Addition is the correct answer to “What does the += operator do in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used for exponentiation in Ruby?
Correct Answer: Option A — **
Detailed Academic Explanation:
** is the correct answer to “Which operator is used for exponentiation in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used for modulo in Ruby?
Correct Answer: Option A — %
Detailed Academic Explanation:
% is the correct answer to “Which operator is used for modulo in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 3 ** 2 in Ruby?
Correct Answer: Option B — 9
Detailed Academic Explanation:
9 is the correct answer to “What is the result of the expression: 3 ** 2 in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: true && false in Ruby?
Correct Answer: Option B — FALSE
Detailed Academic Explanation:
FALSE is the correct answer to “What is the result of the expression: true && false in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 6 / 2 in Ruby?
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What is the result of the expression: 6 / 2 in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used for subtraction in Ruby?
Correct Answer: Option A — -
Detailed Academic Explanation:
- is the correct answer to “Which operator is used for subtraction in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 9 / 2 in Ruby?
Correct Answer: Option B — 2.5
Detailed Academic Explanation:
2.5 is the correct answer to “What is the result of the expression: 9 / 2 in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 3 ** 3 in Ruby?
Correct Answer: Option C — 27
Detailed Academic Explanation:
27 is the correct answer to “What is the result of the expression: 3 ** 3 in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression: 4 > 2 && 5 < 7 in Ruby?
Correct Answer: Option A — TRUE
Detailed Academic Explanation:
TRUE is the correct answer to “What is the result of the expression: 4 > 2 && 5 < 7 in Ruby”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? counter = -50 while counter <0 puts counter counter+=10 end
Correct Answer: Option B — -50 -40 -30 -20 -10
Detailed Academic Explanation:
-50 -40 -30 -20 -10 is the correct answer to “What is the output of the given code? counter = -50 while counter <0 puts counter counter+=10 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_1 = 2**3 != 3**2 || true puts boolean_1
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “What will be the output of the given code? boolean_1 = 2**3 != 3**2 || true puts boolean_1”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid boolean operator?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following is a valid boolean operator”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Ruby does not support ++ operator, it only supports += operator.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Ruby does not support ++ operator, it only supports += operator.”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Assignment operator is also known as relational operator.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Assignment operator is also known as relational operator.”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The == 'is equal to' is known as relational operator.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “The == 'is equal to' is known as relational operator.”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? a = 5 b=10 while a <10 && b<20 puts a+b a+=2 b+=2 end
Correct Answer: Option B — 15 19 23
Detailed Academic Explanation:
15 19 23 is the correct answer to “What is the output of the given code? a = 5 b=10 while a <10 && b<20 puts a+b a+=2 b+=2 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The '=' is used for assigning value to variable?
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “The '=' is used for assigning value to variable”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The given two expression means the same. counter=counter+1 and counter++
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “The given two expression means the same. counter=counter+1 and counter++”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? a = 5 b=10 while (a <10 || b<20)&&true puts a*b a+=2 b+=2 end
Correct Answer: Option B — 50 84 126 176 234
Detailed Academic Explanation:
50 84 126 176 234 is the correct answer to “What is the output of the given code? a = 5 b=10 while (a <10 || b<20)&&true puts a*b a+=2 b+=2 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The boolean operator && only result in true when both the values are true?
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “The boolean operator && only result in true when both the values are true”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_1 = !(700 / 10 == 70) puts boolean_1
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the given code? boolean_1 = !(700 / 10 == 70) puts boolean_1”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_1 = 77 < 78 && 77 < 77 puts boolean_1
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the given code? boolean_1 = 77 < 78 && 77 < 77 puts boolean_1”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_2 = !true && (!true || 100 != 5**2) puts boolean_2
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the given code? boolean_2 = !true && (!true || 100 != 5**2) puts boolean_2”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_1 = !(3 < 4 || false) && (false || true) puts boolean_1
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will be the output of the given code? boolean_1 = !(3 < 4 || false) && (false || true) puts boolean_1”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following are used for comparison?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following are used for comparison”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? a = 22.5 while a >11.5 puts a a-=3.5 end
Correct Answer: Option B — 22.5 11.5
Detailed Academic Explanation:
22.5 11.5 is the correct answer to “What is the output of the given code? a = 22.5 while a >11.5 puts a a-=3.5 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? counter = 100 while counter > 0 puts counter counter/=5 end
Correct Answer: Option A — 100 20 4
Detailed Academic Explanation:
100 20 4 is the correct answer to “What is the output of the given code? counter = 100 while counter > 0 puts counter counter/=5 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? counter = 1 while counter < 11 puts counter counter+=1 end
Correct Answer: Option C — 1..10
Detailed Academic Explanation:
1..10 is the correct answer to “What is the output of the given code? counter = 1 while counter < 11 puts counter counter+=1 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? a=10 b=9 if(a>b) print ("a greater than b") else print "Not greater" end
Correct Answer: Option A — a greater than b
Detailed Academic Explanation:
a greater than b is the correct answer to “What is the output of the given code? a=10 b=9 if(a>b) print ("a greater than b") else print "Not greater" end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Boolean opeartors are also known as logical operators.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Boolean opeartors are also known as logical operators.”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a valid assignment operator?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following is a valid assignment operator”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will the following expression evaluate to? true | | false
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “What will the following expression evaluate to? true | | false”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will the following expression evaluate to? (true && false) | | (!true)
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “What will the following expression evaluate to? (true && false) | | (!true)”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? if(a==10 && b=9) print "true" else print "false" end
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What is the output of the given code? if(a==10 && b=9) print "true" else print "false" end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? test_1 = 17 > 16 puts(test_1) test_2 = 21 <= 30 puts(test_2) test_3 = 9 >= 9 puts(test_3) test_4 = -11 > 4 puts(test_4)
Correct Answer: Option B — True True True False
Detailed Academic Explanation:
True True True False is the correct answer to “What is the output of the given code? test_1 = 17 > 16 puts(test_1) test_2 = 21 <= 30 puts(test_2) test_3 = 9 >= 9 puts(test_3) test_4 = -11 > 4 puts(test_4)”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the **= assignment operator do?
Correct Answer: Option B — It is used as exponent like 2**3=8
Detailed Academic Explanation:
It is used as exponent like 2**3=8 is the correct answer to “What does the **= assignment operator do”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? counter = 100 while counter > 0 puts counter counter-=25 end
Correct Answer: Option A — 100 75 50 25
Detailed Academic Explanation:
100 75 50 25 is the correct answer to “What is the output of the given code? counter = 100 while counter > 0 puts counter counter-=25 end”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the given code? boolean_1 = !true puts boolean_1 boolean_2 = !true && !true puts boolean_2
Correct Answer: Option C — True False
Detailed Academic Explanation:
True False is the correct answer to “What will be the output of the given code? boolean_1 = !true puts boolean_1 boolean_2 = !true && !true puts boolean_2”. This question is standard in competitive examination syllabi for Operators In Ruby.
💡Key Conceptual Anchor:Operators In Ruby
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.