Question 1 of 25
Hints left: 3
Q1
What is the use of else statement?
Q2
What is the output of the code? if 11<2 print "Eleven is less than two" end print "11 is greater"
Q3
What is the output of the given code? if 11>2 puts "Eleven is greater than two" end print "You'r right"
Q4
It's a good habit to give two spaces between if statement and condition.
Q5
If statement inside if statement is called Nested if statements.
Q6
The following syntax is correct for if conditional statement. if condition code end
Q7
What is the output of the code? variable="true".reverse if variable puts "true" else puts "false" end
Q8
What is the output of the code? variable=true if !variable puts "true" else puts "false" end
Q9
What is the output of the given code? if 1>2 puts "false" else puts "True"
Q10
What is the output of the given code? if 79>78 puts "True".upcase if 9>8 puts "True".Upcase if 7==7 puts "equal".downcase end end end
Q11
What is the output of the following? if 1<2 print "one is less than two" end
Q12
What is the output of given code? #counter=1 if counter<=5 puts (counter) counter=counter+1 else puts(counter) counter=counter-1 end
Q13
What is the output of given code? counter=1 if counter<=5 puts (counter) counter=counter+1 else puts(counter) counter=counter-1 end
Q14
What is the output of the given code? if 79>78 puts "True".upcase if 9>8 puts "True".reverse if 7==7 puts "equal".downcase end end end
Q15
Which of the following is valid conditional statement in Ruby?
Q16
The elsif conditional statement is written with an expression.
Q17
If expression. The expression can be of which type?
Q18
What error does the if condition gives if not terminated with end statement?
Q19
Is the following syntax correct? if conditional code... elsif conditional code.. else code end
Q20
What is the output of the code? variable=true if variable puts "true" else puts "false" end
Q21
What is the output of the code? variable="true".length if variable puts "true" else puts "false" end
Q22
Which of the following is valid conditional statement?
Q23
What is the output of the code? if 1>2 puts "false" end else puts "True" end
Q24
It is necessary that always if should come with else block?
Q25
What is the output of the given code? x=1 if x > 2 puts "x is greater than 2" elsif x <= 2 and x!=0 puts "x is 1" else puts "I can't guess the number" end