Ruby interview questions part 2

Ruby interview questions part 2

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. 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" }

Correct Answer is : [1, 2, 3, 4].

2. 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 is : Not equal

3. 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 is : Not equal

4. 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 is : Equal

5. 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 is : Equal

6. 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 is : [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].

7. 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 is : [[1, 2, 3, 4], [0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]].

8. 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 is : [].

9. 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 is : [].

10. 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 is : Error

11. 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 is : Error

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

Correct Answer is : [[1, 2, 3], [0, 0, 0]].

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

Correct Answer is : [[1, 2, 3], [0, 0, 0]].

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

Correct Answer is : [[1, 2, 3, 4, 5], [0, 0, 0, 0]].

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

Correct Answer is : [[1, 2, 3, 4, 5], [0, 0, 0, 0]].

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

Correct Answer is : [[1, 2, 3, 4, 5], [0, 0, 0, 0]].

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

Correct Answer is : [[1, 2, 3, 4, 5], [0, 0, 0, 0]].

18. What is the output of the given code? a=[["a","b"]] b=[["e","a"]] print a + b

Correct Answer is : [[“a”, “b”], [“e”, “a”]].

19. What is the output of the given code? a=[["a","b"]] b=[["e","a"]] print a + b

Correct Answer is : [[“a”, “b”], [“e”, “a”]].

20. It is possible to make array of booleans.

Correct Answer is : TRUE

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon