ExamVeda
Login
Home
11
What is the result of the expression: 5 / 2 in Ruby?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
12
Which of the following is the correct way to declare a constant in Ruby?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
13
Which method is used to check if a variable is nil in Ruby?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
14
What is the method used to check the data type of a variable in Ruby?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
15
What is the output of the expression: "5" + "2" in Ruby?
Discuss
Answer & Solution
Answer: Option C
Solution:
Question: What is the output of the expression: "5" + "2" in Ruby?

Explanation:
In Ruby, when you use the "+" operator with strings (text enclosed in double quotes), it performs string concatenation, not mathematical addition.

This means it joins the two strings together.

So, "5" + "2" combines "5" and "2" to create the new string "52".

Therefore, the correct answer is Option C: 52

Important Note: If you wanted to perform mathematical addition, you would need to use numbers without quotes, like 5 + 2, which would result in 7. But in this case, because the inputs are strings, Ruby treats the "+" as a string concatenation operator.
16
What is the method used to check if a variable is defined in Ruby?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
17
What is the correct syntax to declare and initialize a variable in Ruby?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
18
Which of the following is a valid way to declare a variable in Ruby?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
19
What is the data type of the value "Hello, World" in Ruby?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
20
What is the method used to check if a variable is empty in Ruby?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board