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

2/3

Page

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

What is the correct way to concatenate two strings in Ruby?

Select an option to see the answer and solution.

Which method is used to convert a string to uppercase in Ruby?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the correct way to declare a variable in Ruby without assigning a value?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of the following is the correct way to declare a variable in Ruby with a default value?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the output of the expression: "10" * 3 in Ruby?

Select an option to see the answer and solution.

Which method is used to convert a string to an array of characters in Ruby?

Select an option to see the answer and solution.

What is the method used to check if a variable is of a specific class in Ruby?

Select an option to see the answer and solution.

Which of the following is the correct way to define a variable in Ruby?

Select an option to see the answer and solution.

What is the method used to check if a string contains a specific substring in Ruby?

Select an option to see the answer and solution.

What is the result of the expression: 10 % 3 in Ruby?

Select an option to see the answer and solution.

In Ruby, what is the keyword used to define a constant?

Select an option to see the answer and solution.

Which of the following is the correct way to define a range in Ruby?

Select an option to see the answer and solution.

What does the 'return' keyword do in Ruby methods?

Select an option to see the answer and solution.

What is the correct way to declare and initialize an array in Ruby?

Select an option to see the answer and solution.

In Ruby, what is the default file extension for Ruby files?

Select an option to see the answer and solution.

What does the 'chomp' method do in Ruby?

Select an option to see the answer and solution.

What is the correct syntax for a multiline comment in Ruby?

Select an option to see the answer and solution.