| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

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

Total Questions: 20

1. What will we the output of the given code? I'am Learning RUBY Language.downcase

Correct Answer is : unterminated string meets end of file

2. Methods should not be written inside double quotes.

Correct Answer is : TRUE

3. hat is the output of the given code? age = 5 case age when 0 .. 2 puts "baby" when 3 .. 6 puts "little child" when 7 .. 12 puts "child" when 13 .. 18 puts "youth" else puts "adult" end

Correct Answer is : little child

4. he following syntax is used for the ruby case statement. case expression when expression , expression ... then code ... else code end

Correct Answer is : TRUE

5. hat is the output of the given code? age = 4 case age puts "baby" when 0 .. 2 puts "little child" when 3 .. 6 puts "child" when 7 .. 12 puts "youth" when 13 .. 18 puts "adult" else end

Correct Answer is : syntax error

6. What is the output of the given code? string = gets.chomp case string when string = "a" print "alphabet a" when string = "b" print "alphabet b" when string = "c" print "alphabet c" else print "some other alphabet" end

Correct Answer is : b

7. The expression specified by the when clause is evaluated as the left operand. If no when clauses match, case executes the code of the else clause.

Correct Answer is : TRUE

8. What is the output of the given code? length=gets.chomp case length.length when length=4 print "length is 4" when length=5 print "length is 5" end

Correct Answer is : ruby

9. What is the output of the given code? length=gets.chomp case length.reverse.length when length=4 print "length is 4" when length=5 print "length is 5" end

Correct Answer is : ruby

10. What is the output of the given code? l=9 case l print "ruby" when l==9 print "language" when l==10 end

Correct Answer is : Syntax error

11. A case statement compares the expression specified by case and that specified by when using the === operator and executes the code of the when clause that matches.

Correct Answer is : TRUE

12. What is the use of else statement?

Correct Answer is : When the if condition is false and if else condition is true then only it will get executed

13. s the following syntax correct? if conditional code... elsif conditional code.. else code end

Correct Answer is : TRUE

14. What is the output of the given code? if 1>2 puts "false" else puts "True"

Correct Answer is : Syntax error

15. What is the output of the code? if 1>2 puts "false" end else puts "True" end

Correct Answer is : Syntax error

16. What is the output of the code? variable=true if variable puts "true" else puts "false" end

Correct Answer is : TRUE

17. What is the output of the code? variable="true".reverse if variable puts "true" else puts "false" end

Correct Answer is : TRUE

18. What is the output of the code? variable=true if !variable puts "true" else puts "false" end

Correct Answer is : FALSE

19. What is the output of the code? variable="true".length if variable puts "true" else puts "false" end

Correct Answer is : TRUE

20. Which of the following is valid conditional statement?

Correct Answer is : else