All Ruby quizzes
Intermediate30 questions60 minutes

Ruby Intermediate Quiz

Explore blocks, iterators, modules, exceptions, file I/O, and metaprogramming basics

Start the quiz

Sample questions from this quiz

A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.

1. What is a module?

  • Container for methods and constants; used for mixins
  • Namespace
  • Class alternative
  • Package
Show answer

Answer: Container for methods and constants; used for mixins. Modules group methods/constants. Use for namespacing and mixins. module MyModule; end. Include for instance methods, extend for class methods. Cannot instantiate.

2. What is the difference between include and extend?

  • extend is faster
  • include is deprecated
  • No difference
  • include adds instance methods, extend adds class methods
Show answer

Answer: include adds instance methods, extend adds class methods. include mixes module methods as instance methods. extend mixes as class methods. prepend inserts before (override). Use for different composition needs.

3. What is a lambda?

  • Function object
  • Closure
  • Anonymous function with -> or lambda
  • Proc
Show answer

Answer: Anonymous function with -> or lambda. Lambda: square = ->(x) { x * 2 } or lambda { |x| x * 2 }. Call with .call(). Strict argument checking. return exits lambda only. Closure captures variables.

Frequently asked questions

How many questions are in this Ruby quiz?+

30 questions, with a 60-minute time limit. Every question includes a written explanation of the correct answer.

Is this Ruby quiz free?+

Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.

What level is the intermediate quiz aimed at?+

Explore blocks, iterators, modules, exceptions, file I/O, and metaprogramming basics

Can I use this to prepare for a Ruby interview?+

Yes. The questions cover the topics that come up in Ruby technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.

Ready to test your Ruby?

30 questions, 60 minutes. Free, no sign-up.

Start now