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
🎉 Set complete! All 23 questions answered.
Question 1 of 23
★ FPSC
★ PPSC
★ 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
[[1, 2, 3, 4, 5], [0, 0, 0, 0]]. is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 2 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option C — Not equal
Detailed Academic Explanation:
Not equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 3 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following? array = [100, 200, 300, 400, 500] print array[4]
Correct Answer: Option B — 500
Detailed Academic Explanation:
500 is the correct answer to “What will be the output of the following? array = [100, 200, 300, 400, 500] print array[4]”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 4 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option A — Equal
Detailed Academic Explanation:
Equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 5 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option C — [].
Detailed Academic Explanation:
[]. is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 6 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option A — Equal
Detailed Academic Explanation:
Equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 7 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option B — Not equal
Detailed Academic Explanation:
Not equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 8 of 23
★ FPSC
★ PPSC
★ 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" }
[1, 2, 3, 4]. [0, 0, 0, 0]. [[1, 2, 3, 4], [0, 0, 0, 0]]. is the correct answer to “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" }”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 9 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following? array = [100, 200, 300, 400, 500] print "array[5]"
Correct Answer: Option A — array[5].
Detailed Academic Explanation:
array[5]. is the correct answer to “What will be the output of the following? array = [100, 200, 300, 400, 500] print "array[5]"”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 10 of 23
★ FPSC
★ PPSC
★ 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
[[1, 2, 3], [0, 0, 0]]. is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 11 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be output of the given code? my_array = [1, 2, 3, 4] print my_array
Correct Answer: Option A — [1, 2, 3, 4].
Detailed Academic Explanation:
[1, 2, 3, 4]. is the correct answer to “What will be output of the given code? my_array = [1, 2, 3, 4] print my_array”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 12 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
It is possible to make array of booleans.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “It is possible to make array of booleans.”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 13 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option A — Equal
Detailed Academic Explanation:
Equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 14 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option A — They are equal
Detailed Academic Explanation:
They are equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 15 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option C — Not equal
Detailed Academic Explanation:
Not equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 16 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option C — o TRUE FALSE
Detailed Academic Explanation:
o TRUE FALSE is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 17 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Array of arrays are called multidimensional arrays.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “Array of arrays are called multidimensional arrays.”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 18 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]
Correct Answer: Option C — 2 language
Detailed Academic Explanation:
2 language is the correct answer to “What is the output of the given code? a=["hey", "ruby", "language"] b=[1, 2, 3] puts b[1] puts a[2]”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 19 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array
Correct Answer: Option A — ["a","e","i","o","u"].
Detailed Academic Explanation:
["a","e","i","o","u"]. is the correct answer to “What is the output of the given code? string_array = ["a","e","i","o","u"] print string_array”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 20 of 23
★ FPSC
★ PPSC
★ 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
[[1, 2, 3, 4, 5], [0, 0, 0, 0]]. is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 21 of 23
★ FPSC
★ PPSC
★ 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
Correct Answer: Option B — Equal
Detailed Academic Explanation:
Equal is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 22 of 23
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Each element in an array has an index and the starting index is index 1.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “Each element in an array has an index and the starting index is index 1.”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings In Ruby
Question 23 of 23
★ FPSC
★ PPSC
★ 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
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]. is the correct answer to “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”. This question is standard in competitive examination syllabi for Arrays_ Hashes And Strings In Ruby.
💡Key Conceptual Anchor:Arrays_ Hashes And Strings 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.