ExamVeda
Login
Home
81
The following syntax is used for the ruby case statement.
case expression
when expression , expression ... then
   code ...
else
   code 
end
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
82
What 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
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
83
What is the output of the given code?
for counter in 1..5
case counter
when 0 .. 2
    puts counter
    puts "baby"
when 3 .. 6
    puts counter
    puts "little child"
when 7 .. 12
    puts counter
    puts "child"
else
    puts counter
    puts "adult"
end
end
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
84
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
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
85
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.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
86
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
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
87
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
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
88
What is the output of the given code?
l=9
case l
print "ruby" when l==9
print "language" when l==10
end
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
89
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.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
90
While loop checks the condition and the loop keeps on running till the condition is true, it stops when the condition becomes false.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board