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