Skip to main content

Arrays_ Hashes And Strings In Ruby — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Arrays_ Hashes And Strings In Ruby — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
23
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
28 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
23

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/23 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4,5],[0,0,0,0]] array2 = [[1,2,3],[0,0,0]] print !array1

Question 2 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4],[0,0,0,0]] array2 = [[1,2,3],[0,0,0,0]] if array1==array2 print "Equal" else print "Not equal" end

Question 3 of 23
★ FPSC ★ PPSC

What will be the output of the following? array = [100, 200, 300, 400, 500] print array[4]

Question 4 of 23
★ FPSC ★ PPSC

What is the output of the given code? a=[1,2,3,4,5] b=[1,2,4,6,8] if a[3]==b[2] print "Equal" end

Question 5 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4],[0,0,0,0]] array2 = [[1,2,3,4],[0,0,0,0]] print array1-array2

Question 6 of 23
★ FPSC ★ PPSC

What will be the output of the following? array1 = [1,2,3] array2 = [0,0,0] if array1 == array2 print "Equal" else print "Not equal" end

Question 7 of 23
★ FPSC ★ PPSC

What will be the output of the following? array1 = [100, 200, 300, 400, 500] array2 = [1,2,3,4,5] if array1 == array2 print "They are equal" else print "Not equal" end

Question 8 of 23
★ FPSC ★ PPSC

What is the output of the given code? multi_d_array = [[1,2,3,4],[0,0,0,0]] multi_d_array.each { |x| puts "#{x}\n" }

Question 9 of 23
★ FPSC ★ PPSC

What will be the output of the following? array = [100, 200, 300, 400, 500] print "array[5]"

Question 10 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4],[0,0,0,0]] array2 = [[1,2,3],[0,0,0]] print array1 && array2

Question 11 of 23
★ FPSC ★ PPSC

What will be output of the given code? my_array = [1, 2, 3, 4] print my_array

Question 12 of 23
★ FPSC ★ PPSC

It is possible to make array of booleans.

Question 13 of 23
★ FPSC ★ PPSC

What is the output of the given code? a=[1,2,3,4,5] b=[1,2,3,4,5] if a==b print "Equal" else print "Not equal" end

Question 14 of 23
★ FPSC ★ PPSC

What will be the output of the following? array1 = [0,0,0] array2 = [0,0,0] if array1 == array2 print "They are equal" else print "Not equal" end

Question 15 of 23
★ FPSC ★ PPSC

What is the output of the given code? a=["hey", "ruby", "language"] b=["hey", "language", "ruby"] if a==b print "Equal" else print "Not equal" end

Question 16 of 23
★ FPSC ★ PPSC

What is the output of the given code? string_array = ["a","e","i","o","u"] boolean_array = ["True","False"] puts string_array[3] puts boolean_array

Question 17 of 23
★ FPSC ★ PPSC

Array of arrays are called multidimensional arrays.

Question 18 of 23
★ FPSC ★ PPSC

What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]

Question 19 of 23
★ FPSC ★ PPSC

What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array

Question 20 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4,5],[0,0,0,0]] array2 = [[1,2,3],[0,0,0]] print array1 || array2

Question 21 of 23
★ FPSC ★ PPSC

What is the output of the given code? array1 = [[1,2,3,4],[0,0,0,0]] array2 = [[1,2,3,4],[0,0,0,0]] if array1==array2 print "Equal" else print "Not equal" end

Question 22 of 23
★ FPSC ★ PPSC

Each element in an array has an index and the starting index is index 1.

Question 23 of 23
★ FPSC ★ PPSC

What is the output of the given code? multi_d_array = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]] print multi_d_array

✓ 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 →