Test Your Knowledge About Ruby Programming! Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By E.stryker
E
E.stryker
Community Contributor
Quizzes Created: 1 | Total Attempts: 2,669
| Attempts: 2,669 | Questions: 12
Please wait...
Question 1 / 12
0 %
0/100
Score 0/100
1. Ruby is an object-oriented general-purpose programming language.

Explanation

Ruby allow users to manipulate data structures called objects to build and execute programs.

Submit
Please wait...
About This Quiz
Test Your Knowledge About Ruby Programming! Quiz - Quiz

Ruby is an Object-Oriented and interpreted scripting language which executes instructions directly and freely, without compiling a program into machine-language instructions that have similar syntaxes like another programming language for eg. C and Java. This quiz has been made to test your skills and knowledge about the basic syntax of... see morethe Ruby programming language. So, let's try out the quiz. All the best!
see less

Personalize your quiz and earn a certificate with your name on it!
2. 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 }."

Explanation

x, y, z assigned the values 12, 36, 72 and then arithmetic operations performed on them.

Submit
3. Which of the following is supported by Ruby?

Explanation

Ruby supports all the features because it is a object oriented programming language.

Submit
4. Variables that start a dollar sign are what kind of variables in Ruby

Explanation

In Ruby, variables that start with a dollar sign ($) are considered global variables. Global variables can be accessed and modified from anywhere in the program, making them accessible across different scopes and classes. This means that any changes made to a global variable in one part of the program will affect its value in other parts of the program as well.

Submit
5. Ruby is what kind of programming language?

Explanation

Ruby is a programming language that is strongly typed, meaning that it enforces strict type checking, and dynamically typed, meaning that variable types are determined at runtime rather than during compilation. In Ruby, variables can hold values of any type and can be reassigned to different types, allowing for flexibility in programming.

Submit
6. The following is a primitive type in Ruby

Explanation

A primitive type is a type that is not an object; i.e. it does not inherit from the Object class

Submit
7. Variables that start with a capital letter are what kind of variables in Ruby

Explanation

In Ruby, variables that start with a capital letter are considered constants. Constants are variables whose value cannot be changed once assigned. They are typically used to represent values that are not meant to be modified throughout the program. Therefore, the correct answer is "None of the above" as the given options (local variable, global variable, instance variable, and class variable) do not include constants.

Submit
8. Variables that start with two '@' symbols are what kind of variables in Ruby

Explanation

Variables that start with two '@' symbols in Ruby are class variables. Class variables are shared among all instances of a class and can be accessed and modified by any instance of the class. They are defined within the class but outside of any method or constructor.

Submit
9.
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}"

Explanation

The code prompts the user to enter their first name and stores it in the variable first_name.

It capitalizes the first letter of the first name using .capitalize method and stores it in variable a.

It then capitalizes the first letter of the first name in place using capitalize!.

Next, the code prompts the user to enter their last name and stores it in the variable last_name.

It capitalizes the first letter of the last name using .capitalize method and stores it in variable b.

However, the capitalize method on last_name is not applied in place, so the last name remains unchanged.

Finally, it prints out the message with #{first_name} and #{last_name}, where first_name and last_name are both capitalized due to previous modifications.

Submit
10. What does %x!ls! represents?

Explanation

It is same as back tick command output `ls`.

Submit
11. What does %{Learn ruby language} represents?

Explanation

In Ruby, %{...} is a way to delimit a string, similar to single or double quotes. It allows for string interpolation and can contain any characters, including spaces and special characters. Therefore, %{Learn Ruby language} represents the string "Learn Ruby language".

Submit
12. Which of the following is the valid string method?

Explanation

There is no predefined method which can reverse an already reversed string.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 8, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 08, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 28, 2007
    Quiz Created by
    E.stryker
Cancel
  • All
    All (12)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Ruby is an object-oriented general-purpose programming language.
What is the output of the given code? ...
Which of the following is supported by Ruby?
Variables that start a dollar sign are what kind of variables in Ruby
Ruby is what kind of programming language?
The following is a primitive type in Ruby
Variables that start with a capital letter are what kind of variables...
Variables that start with two '@' symbols are what kind of variables...
What is the output of the code? ...
What does %x!ls! represents?
What does %{Learn ruby language} represents?
Which of the following is the valid string method?
Alert!

Advertisement