Exam Code: Ruby-Programmer-Gold
Exam Questions: 160
Ruby Association Certified Ruby Programmer Gold version 3
Updated: 06 Jan, 2026
Viewing Page : 1 - 16
Practicing : 1 - 5 of 160 Questions
Question 1

In Ruby, which of the following literals correctly creates a Hash object with default values for undefined keys?

Options :
Answer: B

Question 2

In Ruby, the understanding of operators and their precedence is crucial for writing correct and efficient code. Consider the following Ruby code snippet:

a = 10b = 3result1 = a + b * 2result2 = (a + b) % 3result3 = a ** b / 2 Based on this code, which two of the following statements are true regarding the use of operators and their precedence?

Options :
Answer: A,E

Question 3

Review the following Ruby code snippet:

def divide_numbers(x, y) x / yrescue ZeroDivisionError => e puts "Error: #{e.message}"end result1 = divide_numbers(10, 2)result2 = divide_numbers(10, 0)result3 = begin divide_numbers(10, '5') rescue TypeError => e "Caught: #{e.class}" endresult4 = divide_numbers(10, nil) rescue "Invalid operation" What will be the values of result1, result2, result3, and result4, respectively?

Options :
Answer: D

Question 4

Examine the following Ruby code snippet:

a = 2
b = 3
c = '4'
result1 = a * b
result2 = a * c
result3 = c * b
result4 = c + a

Options :
Answer: B

Question 5

Review the following Ruby code snippet in the context of class inheritance and method access control:

class Product
  def initialize(name, price)
    @name = name
    @price = price
  end
  private
  def price
    @price
  end
end
class Electronic < Product
  def discount_amount(discount_percentage)
    price * discount_percentage / 100.0
  end
  def discounted_price(discount_percentage)
    price - discount_amount(discount_percentage)
  end
end
electronic_item = Electronic.new("Laptop", 1000)
result = electronic_item.discounted_price(20)
What will be the value of result?

Options :
Answer: B

Viewing Page : 1 - 16
Practicing : 1 - 5 of 160 Questions

© Copyrights FreePDFQuestions 2026. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (FreePDFQuestions). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the FreePDFQuestions.