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

6/7

Page

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

Which of the following are valid floating point literal?

Select an option to see the answer and solution.

What is the role of ! at the end of the capitalize method?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the range of octal notation (\nnn)?

Select an option to see the answer and solution.

Which of the following type of comments are valid in ruby?

Select an option to see the answer and solution.

Why do we use =begin and =end?

Select an option to see the answer and solution.

What is the output of the given code?
 x, y, z = 12, 36, 72
    puts "The value of x is #{ x }."
    puts "The sum of x and y is #{ x + y }."
    puts "The average was #{ (x + y + z)/3 }."

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
   a=a.reverse
   puts"My name is #{a}"

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"

Select an option to see the answer and solution.

Objects of which class does the integer from the range -2^30 to 2^(30-1) belong to?

Select an option to see the answer and solution.

What is the output of given code?
puts "what is your first name?"
   name=gets.chomp
   puts "what is your surname?"
   surname=gets.chomp

Select an option to see the answer and solution.

We use semicolon or parentheses after every print or puts statement.

Select an option to see the answer and solution.

What will we the output of the given code?
"I'am Learning RUBY Language".downcase

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.

The .upcase and .capitalize method are used for capitalizing the whole string.

Select an option to see the answer and solution.

The downcase method changes the whole string to smallcase letters.

Select an option to see the answer and solution.

Which sequence can be used to substitute the value of any ruby expression in a string?

Select an option to see the answer and solution.

What does %x!ls! represents?

Select an option to see the answer and solution.

Which of the following datatypes are valid in Ruby?

Select an option to see the answer and solution.

Methods should not be written inside double quotes.

Select an option to see the answer and solution.