Are you a candidate looking to sharpen your skills? Try our practice tests or view sample interview questions & Get hired by the best. Click Here×

Ruby Test

Topics Covered

  • Ruby Basics
  • Control Flow in Ruby
  • Looping with Ruby
  • Array and Hashes
  • Blocks and Sorting
  • Hashes and Symbols
  • Blocks
  • Procs
  • and Lambdas
  • Object Oriented Programming 
  • Modules and Mixins
  • Working with Files
  • Metaprogramming

Useful for hiring

  • Ruby Engineer 
  • Ruby Software Developer (0-3 years experience) 
  • Ruby Developer 

Start hiring job-fit candidates using this assessment

GET A DEMO

"We are impressed with Interview Mocha's comprehensive IT skill test batteries and their ability to provide tailor-made assessments quickly. The results we got from Interview Mocha exceeded our expectations, employees found the tests quick, fun, and a benchmark of their knowledge."

Ajay Garg, Siemens,
Associate Manager
Question

How is it possible to refactor this class correctly?
class NullOrder
  def price_euro
    0.0
  end
  def price_usd
    0.0
  end
end 

Note: There are multiple correct answers to this question.

Answer
    • class NullOrder
      def price_euro
      0.0
      end
      alias price_usd price_euro
      end

    • class NullOrder
      def price
      0.0
      end
      end

    • class NullOrder
      def method_missing(m, *args, &block)
      m.to_s =~ /euro|usd/ ? 0.0 : super
      end
      end

    • class NullOrder
      def method_missing(m, *args, &block)
      m.to_s =~ /price_/ ? 0.0 : super
      end
      end

Question

Given an array, an index and a default value as input. Which code returns the element by that index; if no element exists with given index then return the default value? Index can be a negative integer, which means going over the array backwards from the end.

Note: There are multiple correct answers to this question.

Answer
    • def bar(array, index, value)
      return array[index] if array[index]
      value
      end

    • def bar(array, index, value)
      answer = array[value]
      return answer if answer
      index
      end

    • def bar(array, index, value)
      answer = array[index]
      return value unless answer
      answer
      end

    • def bar(array, index, value)
      answer = array.first
      return answer if value
      index
      end

Question

Which is a shortcut for writing these 2 methods for User class?

  def name=(value)
    @name = value
  end
  def name
    @name
  end

Note: There are multiple correct answers to this question.

Answer
    • class User
      attr_reader :user
      end

    • class User
      attr_writer :user
      end

    • class User
      attr_accessor :user
      end

    • class User
      attr_reader :user
      attr_writer :user
      end

Test details:

Ruby online test enables employers and recruiters to identify potential hires by evaluating working skills and job readiness. For this reason, the emphasis is laid upon evaluating the knowledge of applied skills gained through real work experience, rather than theoretical knowledge. 

Test Details: 20 minutes 

  • 15 Application Oriented Questions

  • 05 Theory Questions 

The combination of Application and Theory questions helps to evaluate Technical as well as practical Skills of Candidates

Test description:

Ruby is one of the flexible and powerful programming languages. This language is used for Web / Internet Development to process text, to create games and also as a part of popular Ruby on Rails framework. Ruby is a high level and interpreted programming language like Python and PERL. Ruby has similar syntax to that of C++ and PERL and is much scalable for big programs execution. Due to its easy and clean syntax, it is easier for a developer to learn Ruby language. This Ruby test is specially designed to check application, practical skills of a Ruby developer – as per Industry Standards. Our Ruby skill test is created and validated by Subject Matter Experts.

Test Topics:

The test contains questions on following topics:

  • Ruby Basics

  • Control Flow in Ruby

  • Looping with Ruby

  • Array and Hashes

  • Blocks and Sorting

  • Hashes and Symbols

  • Blocks, Procs, and Lambdas

  • Object Oriented Programming 

  • Modules and Mixins

  • Working with Files

  • Metaprogramming 

The Ruby test contains MCQ's (Multiple Choice Questions), MAQ's (Multiple Answer Questions), Fill in the Blank, Descriptive, True or False. Using powerful reporting, you will have a detailed analysis of test results to help you make better decisions and predict candidate and employee success. 

Good News! You can customize this test as per your requirement

  • Choose and add questions from Interview Mocha question libraries

  • Add your own set of questions

  • Customize test settings like duration, number of questions, passing score, web proctoring and much more

  • Mail us at support@interviewmocha.com to create a custom test

Looking for a tailor-made test, to suit your assessment needs?

Get in touch

Global companies using Mocha assessments

  • altran
  • credit suisse
  • sephora
  • nielsen
  • capgemini
  • akamai

How Mocha assessments are brewed

Speed up your IT recruitment with Interview Mocha

  • 500+ IT skill tests
  • 20+ coding languages
  • 50+ domain knowledge tests
  • 100+ digital 2.0 skill tests
  • Customer focus aptitude tests
  • Enterprise ready features & more...
GET A DEMO

Why hiring managers and recruiters across the globe love Interview Mocha

Take your first step to hire job fit candidates

GET A DEMO