Skip to main content

Operators In Ruby — Part 1 MCQs with Explanations

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
Question 1 of 40
★ FPSC ★ PPSC

Which operator is used for addition in Ruby?

Question 2 of 40
★ FPSC ★ PPSC

What does the += operator do in Ruby?

Question 3 of 40
★ FPSC ★ PPSC

Which operator is used for exponentiation in Ruby?

Question 4 of 40
★ FPSC ★ PPSC

Which operator is used for modulo in Ruby?

Question 5 of 40
★ FPSC ★ PPSC

What is the result of the expression: 3 ** 2 in Ruby?

Question 6 of 40
★ FPSC ★ PPSC

What is the result of the expression: true && false in Ruby?

Question 7 of 40
★ FPSC ★ PPSC

What is the result of the expression: 6 / 2 in Ruby?

Question 8 of 40
★ FPSC ★ PPSC

Which operator is used for subtraction in Ruby?

Question 9 of 40
★ FPSC ★ PPSC

What is the result of the expression: 9 / 2 in Ruby?

Question 10 of 40
★ FPSC ★ PPSC

What is the result of the expression: 3 ** 3 in Ruby?

Question 11 of 40
★ FPSC ★ PPSC

What is the result of the expression: 4 > 2 && 5 < 7 in Ruby?

Question 12 of 40
★ FPSC ★ PPSC

What is the output of the given code? counter = -50 while counter <0 puts counter counter+=10 end

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_1 = 2**3 != 3**2 || true puts boolean_1

Question 14 of 40
★ FPSC ★ PPSC

Which of the following is a valid boolean operator?

Question 15 of 40
★ FPSC ★ PPSC

Ruby does not support ++ operator, it only supports += operator.

Question 16 of 40
★ FPSC ★ PPSC

Assignment operator is also known as relational operator.

Question 17 of 40
★ FPSC ★ PPSC

The == 'is equal to' is known as relational operator.

Question 18 of 40
★ 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

Question 19 of 40
★ FPSC ★ PPSC

The '=' is used for assigning value to variable?

Question 20 of 40
★ FPSC ★ PPSC

The given two expression means the same. counter=counter+1 and counter++

Question 21 of 40
★ 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

Question 22 of 40
★ FPSC ★ PPSC

The boolean operator && only result in true when both the values are true?

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_1 = !(700 / 10 == 70) puts boolean_1

Question 24 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_1 = 77 < 78 && 77 < 77 puts boolean_1

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_2 = !true && (!true || 100 != 5**2) puts boolean_2

Question 26 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_1 = !(3 < 4 || false) && (false || true) puts boolean_1

Question 27 of 40
★ FPSC ★ PPSC

Which of the following are used for comparison?

Question 28 of 40
★ FPSC ★ PPSC

What is the output of the given code? a = 22.5 while a >11.5 puts a a-=3.5 end

Question 29 of 40
★ FPSC ★ PPSC

What is the output of the given code? counter = 100 while counter > 0 puts counter counter/=5 end

Question 30 of 40
★ FPSC ★ PPSC

What is the output of the given code? counter = 1 while counter < 11 puts counter counter+=1 end

Question 31 of 40
★ 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

Question 32 of 40
★ FPSC ★ PPSC

Boolean opeartors are also known as logical operators.

Question 33 of 40
★ FPSC ★ PPSC

Which of the following is a valid assignment operator?

Question 34 of 40
★ FPSC ★ PPSC

What will the following expression evaluate to? true | | false

Question 35 of 40
★ FPSC ★ PPSC

What will the following expression evaluate to? (true && false) | | (!true)

Question 36 of 40
★ FPSC ★ PPSC

What is the output of the given code? if(a==10 && b=9) print "true" else print "false" end

Question 37 of 40
★ 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)

Question 38 of 40
★ FPSC ★ PPSC

What does the **= assignment operator do?

Question 39 of 40
★ FPSC ★ PPSC

What is the output of the given code? counter = 100 while counter > 0 puts counter counter-=25 end

Question 40 of 40
★ FPSC ★ PPSC

What will be the output of the given code? boolean_1 = !true puts boolean_1 boolean_2 = !true && !true puts boolean_2

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →