Vidyalelo
Ruby Programming · all questions

Basic Syntax in Ruby
practice.

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

134

Questions

4/7

Page

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

Which of the following features does the 2.0 version of ruby supports?

Select an option to see the answer and solution.

Which of the following is the valid string method?

Select an option to see the answer and solution.

The .length method is used to check number of characters.

Select an option to see the answer and solution.

What is the size of an integer data type in ruby?

Select an option to see the answer and solution.

What is the output of the given code?
Ans=Ruby
    puts "#{Ans} is an oop language"
    puts "It is very efficient langauge"
    puts "#{expr} is used on rails platform"

Select an option to see the answer and solution.

This the right way to comment a single line.
“Ruby”.length # I’m a single line comment!

Select an option to see the answer and solution.

Which of the following is supported by Ruby?

Select an option to see the answer and solution.

Space between 2+5 or 2 + 5 is valid but =begin and = begin is not valid.

Select an option to see the answer and solution.

first_name,Last_name=gets.chomp,gets.chomp is the correct way to get the input from the user.

Select an option to see the answer and solution.

Ruby can be used for developing internet and intranet applications.

Select an option to see the answer and solution.

What is the output of the given code?
"Ruby Language".length
       = begin
       calculate length
       = end

Select an option to see the answer and solution.

What will be the output of the given code?
"I'am learning Ruby Language".reverse.upcase.length

Select an option to see the answer and solution.

Why do we use comments?

Select an option to see the answer and solution.

How to comment multiple lines in ruby?

Select an option to see the answer and solution.

What will be the output of the given code?
"Come let's learn.reverse Ruby.length language".upcase

Select an option to see the answer and solution.

What is the output of given code?
string="I'am Learning RUBY Language".downcase
    string.upcase

Select an option to see the answer and solution.

What is the output of the code?
print "What's your first name?"
   first_name=gets.chomp
   a=first_name.capitalize
   first_name.capitalize!
   print "What's your last name?"
   last_name=gets.chomp
   b=last_name.capitalize
   last_name.capitalize
   puts "My name is #{first_name} #{last_name}"

Select an option to see the answer and solution.

What is the output of the following?
ruby.reverse

Select an option to see the answer and solution.

What is the output of the given code?
print "what's your first name?"
   first_name=gets.chomp
   a=first_name.capitalize
   "first_name.capitalize!".reverse
   puts"My name is #{first_name}"

Select an option to see the answer and solution.

What is the output of the following?
"Iam learning ruby language".length

Select an option to see the answer and solution.