Increase your chances of passing the Ruby Association Ruby-Programmer-Gold exam questions on your first try. Practice with our free online Ruby-Programmer-Gold exam mock test designed to help you prepare effectively and confidently.
Evaluate the following Ruby code snippet that involves the forwardable and date modules:require 'forwardable'require 'date' class Project extend Forwardable def_delegators :@deadline, :month, :day attr_accessor :name attr_reader :deadline def initialize(name, deadline) @name = name @deadline = Date.parse(deadline) endend project = Project.new("Ruby Exam Prep", "2024-06-30")result1 = project.monthresult2 = project.dayproject.deadline = Date.parse("2024-07-15")result3 = project.month What will be the values of result1, result2, and result3, respectively?
In Ruby, which of the following literals correctly creates a Hash object with default values for undefined keys?
In Ruby, the use of blocks is a fundamental concept for iterating over collections and executing code repeatedly. Examine the following Ruby code snippet:numbers = [1, 2, 3, 4, 5]sum = 0numbers.each { |number| sum += number }doubled = numbers.map { |number| number * 2 } Based on this code, which two of the following statements are true regarding the use and functionality of blocks?
Consider the following Ruby code snippet involving the implementation and usage of the Comparable module:class TimeRange include Comparable attr_reader :start_time, :end_time def initialize(start_time, end_time) @start_time = start_time @end_time = end_time end def (other) return nil unless other.is_a?(TimeRange) [start_time, end_time] [other.start_time, other.end_time] endend time_range1 = TimeRange.new(10, 20)time_range2 = TimeRange.new(15, 25)time_range3 = TimeRange.new(10, 20) result1 = time_range1 time_range3 What will be the values of result1, result2, and result3, respectively?
Analyze the following Ruby code snippet in the context of class design and instance variable management:class Book attr_reader :title, :author @@total_books = 0 def self.total_books @@total_books end def initialize(title, author) @title = title @author = author @@total_books += 1 endendclass Library attr_reader :books def initialize @books = [] end def add_book(book) @books
© Copyrights FreeMockExams 2026. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (FreeMockExams). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the FreeMockExams.