Vidyalelo
Ruby Programming · all questions

Data Types and Variables in Ruby
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

45

Questions

1/3

Page

Pick an option on a question to see the right answer and solution.

Which of the following is NOT a valid data type in Ruby?

Select an option to see the answer and solution.

What is the data type of the value 3.14 in Ruby?

Select an option to see the answer and solution.

What is the default value of a variable in Ruby if not initialized?

Select an option to see the answer and solution.

Which symbol is used to declare a variable in Ruby?

Select an option to see the answer and solution.

What does the 'nil' value represent in Ruby?

Select an option to see the answer and solution.

Which of the following is a valid variable name in Ruby?

Select an option to see the answer and solution.

What is the method used to convert a string to an integer in Ruby?

Select an option to see the answer and solution.

What is the method used to convert a string to a float in Ruby?

Select an option to see the answer and solution.

What is the data type of the value true in Ruby?

Select an option to see the answer and solution.

What is the method used to convert a value to string in Ruby?

Select an option to see the answer and solution.

What is the result of the expression: 5 / 2 in Ruby?

Select an option to see the answer and solution.

Which of the following is the correct way to declare a constant in Ruby?

Select an option to see the answer and solution.

Which method is used to check if a variable is nil in Ruby?

Select an option to see the answer and solution.

What is the method used to check the data type of a variable in Ruby?

Select an option to see the answer and solution.

What is the output of the expression: "5" + "2" in Ruby?

Select an option to see the answer and solution.

What is the method used to check if a variable is defined in Ruby?

Select an option to see the answer and solution.

What is the correct syntax to declare and initialize a variable in Ruby?

Select an option to see the answer and solution.

Which of the following is a valid way to declare a variable in Ruby?

Select an option to see the answer and solution.

What is the data type of the value "Hello, World" in Ruby?

Select an option to see the answer and solution.

What is the method used to check if a variable is empty in Ruby?

Select an option to see the answer and solution.