Ruby Programming Training Quiz #2

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 Ary.Alva
A
Ary.Alva
Community Contributor
Quizzes Created: 2 | Total Attempts: 2,178
| Attempts: 1,710 | Questions: 15
Please wait...
Question 1 / 15
0 %
0/100
Score 0/100
1. Which statement uses an instance variable?

Explanation

The correct answer is C - The instance variable starts with a single at-sign

Submit
Please wait...
About This Quiz
Ruby Programming Training Quiz #2 - Quiz

Test your proficiency in Ruby. Take other quizzes in Ruby series.
. . . I'd love to hear from you. Please leave your comments. . .
Best of luck!
*** Ary Alva ***

Personalize your quiz and earn a certificate with your name on it!
2. What is the right way to create subclass Bird based on the calss Animal?

Explanation

The correct answer is B - calss Bird

Submit
3. What is the output of this statement
a= 3_1_4_1_5_9_2_6; puts a

Explanation

The correct answer is C. Underscore characters are ignored in the digit string.

Submit
4. Which of these statements is false?

Explanation

The correct answer is E - All of the above statements are false.

Submit
5. A=5
b=7
Which of the statements below is illegal in Ruby?

Explanation

The correct answer is C. The true is a spacial constant in Ruby and we can not assign any value to constants like self, true, false, nil, __FILE__, __LINE__

Submit
6. Which statement prints the objec animal?

Explanation

B and C are both correct answers. The statement p animal is equivalent of the statement puts animal.inspect

Submit
7. Which statement below contains a symbol?

Explanation

The correct answers are A and B

Submit
8. What is the correct way of defining a method with variable number of parameters?

Explanation

The correct answers are B and C - The variable number of parameters in a method is denoted by prefixing the last parameter with an asterisk.

Submit
9. Which statement prints the Ruby interpreter load path, which is used to search for files listed with the "require" directive?

Explanation

The correct answer is C - the statement puts $: prints out Ruby interpreter load path.

Submit
10. Which identifyer listed below can be used as a name of a local variable?

Explanation

The correct answer is B. Ruby is a case sensitive language, so Alias is not the same a a key word alias. #alias is a comment and %alias is illegal, since alias is a keyword in Ruby and can not be used as a delimiter which is expected after %.

Submit
11. What is the right way to continue Ruby statement on a second line?

Explanation

The coreect answers are B and C

Submit
12. Class Animal is defined in the module Zoo which is stored in the file zoo_file.rb
Which statement is true?

Explanation

The statements A, D and E are correct. Ruby code can be grouped in the module. To use classes defined in the module, the statement require 'module_file_name' has to be present. To allow using the class methods without ModuleName::, the statement "include ModuleName" has to be included in the code after the statement "require 'module_file'" and before any methods are used.

Submit
13. Which statement allows to modify instance variable @sound?

Explanation

The correct answers are B, D and E. The accessor which allows to modify an instance variable @sound can be any of these three statements:
attr :sound, TRUE
attr_accessor :sound
attr_writer :sound

Submit
14. What is the right way to define "Here document" string in Ruby?

Explanation

The correct answers are A and D. The here document is interpolated unles singlo quotes around the delimiter are used.

Submit
15. Which statement is false?

Explanation

Statements A, C, D, and E are false.

Submit
View My Results

Quiz Review Timeline (Updated): Jun 17, 2024 +

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

  • Current Version
  • Jun 17, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • May 19, 2010
    Quiz Created by
    Ary.Alva
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which statement uses an instance variable?
What is the right way to create subclass Bird based on the calss...
What is the output of this statementa= 3_1_4_1_5_9_2_6; puts a
Which of these statements is false?
A=5b=7Which of the statements below is illegal in Ruby?
Which statement prints the objec animal?
Which statement below contains a symbol?
What is the correct way of defining a method with variable number...
Which statement prints the Ruby interpreter load path, which is used...
Which identifyer listed below can be used as a name of a local...
What is the right way to continue Ruby statement on a second line?
Class Animal is defined in the module Zoo which is...
Which statement allows to modify instance variable @sound?
What is the right way to define "Here document" string in Ruby?
Which statement is false?
Alert!

Advertisement