JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Ruby interview questions part 13
Ruby interview questions part 13
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 13
1. What is the output of the given code? m=0 loop do print "ruby" m+=1 break if m==5 end
A. rubyrubyrubyrubyrubyruby
B. rubyrubyrubyrubyruby
C. Error
D. None of the mentioned
Show Correct Answer
Correct Answer is :
rubyrubyrubyrubyruby
2. What is the output of the given code? m=0 loop do puts m*10 m+=1 break if m==5 end
A. 0 10 20 30 40
B. 10 20 30 40 50
C. Error
D. None of the mentioned
Show Correct Answer
Correct Answer is :
0 10 20 30 40
3. What is the output of the given code? m=0 loop do puts 101 m+=1 break if m==5 end
A. 101 101 101 101 101
B. 10 20 30 40 50
C. Error
D. None of the mentioned
Show Correct Answer
Correct Answer is :
101 101 101 101 101
4. What is the output of the given code? m=5 loop do m-=1 break if m==0 end
A. 1 2 3 4 5
B. 10 20 30 40 50
C. Error
D. Nil
Show Correct Answer
Correct Answer is :
Nil
5. While loop checks the condition and the loop keeps on running till the condition is true, it stops when the condition becomes false.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
6. What is the output of the given code? counter = 1 while counter < 11 puts counter counter = counter + 1 end
A. Prints the number from 1 to 10
B. Prints the number from 1 to 11
C. Prints the number from 2 to 10
D. Infinite loop
Show Correct Answer
Correct Answer is :
Prints the number from 1 to 10
7. What is the output of the given code? counter = true while counter !=false puts counter end
A. TRUE
B. FALSE
C. Syntax error
D. Infinite loop
Show Correct Answer
Correct Answer is :
Infinite loop
8. What is the output of the given code? i = 0 while i < 5 puts i i=(i+1)**2 end
A. 1 2 3 4 5
B. 36529
C. 0 1
D. 45295
Show Correct Answer
Correct Answer is :
36529
9. What is the output of the given code? a=5 b=15 while a&&b puts a+b end
A. 5..15
B. 20
C. Infinite loop
D. 45427
Show Correct Answer
Correct Answer is :
Infinite loop
10. What is the output of the given code? a=5 b=15 while b>a puts a*(b-a) while a>b a+=1 b-=1 end end
A. 5..15
B. 50
C. Infinite loop
D. 5 50
Show Correct Answer
Correct Answer is :
Infinite loop
11. What is the output of the given code? i = 3 while i > 0 do print i i -= 1 end
A. 3
B. 321
C. Infinite loop
D. 3 2 1 0
Show Correct Answer
Correct Answer is :
321
12. What is the output of the given code? i = 50 while i > 25 do print 50/i i -= 1 end
A. 50..25
B. 50..1
C. Infinite loop
D. 1111111111111111111111111
Show Correct Answer
Correct Answer is :
1111111111111111111111111
13. What is the output of the given code? a = 5 b=10 while a
A. 45422
B. 50 56
C. Infinite loop
D. 5 6 7 8 9 10
Show Correct Answer
Correct Answer is :
50 56
Similar Interview Questions
Search for latest jobs
Find Jobs