Home / Programming MCQs / Ruby MCQs / Question
V
Q. What will be the output of the given code?
boolean_var = 3**2 != 2**3 || true puts boolean_var
Explanation:
2**3=8 and 3**2=9 both the values are not equal is true and true or true will evaluate to true hence the overall expression will evaluate to true.
You must be Logged in to update hint/solution
Which method is used to find the first occurrence of a pattern in a string in Ruby?
What does the \w character class represent in a regular expression in Ruby?
How do you check if a key exists in a hash in Ruby?
What is the main difference between instance_eval and class_eval in Ruby?
What is the difference between && and & operators?
Why can not we use quotation marks (' or ") with boolean?
Which method is used to check if a Time object occurs after another Time object in Ruby?
Discusssion
Login to discuss.