ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What is the output of the given code
a=["hey", "ruby", "language"]
b=["hey", "ruby", "language"]
if a==b
print "Equal"
else
print "Not equal"
end
Correct Answer: A — Equal
a[3] is 4 and b[3] is 6 (b=[1,2,4,6]). Since 4 != 6, the condition is false. Wait — actually a[3]==b[3] is 4==6 → false, so 'Equal' is NOT printed. However, b[2]=4 and a[2]=3 → a[3]=4, b[2]=4 → Equal is printed when a[3]==b[2]. Output: Equal.