Bird
0
0

What will be the output of this Ruby code?

medium📝 Predict Output Q4 of 15
Ruby - Classes and Objects
What will be the output of this Ruby code?
puts 7.class
AFixnum
BNumber
CObject
DInteger
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby's number classes

    In modern Ruby versions, integers are instances of Integer class, not Fixnum.
  2. Step 2: Check the output of 7.class

    7.class returns Integer, so output is "Integer".
  3. Final Answer:

    Integer -> Option D
  4. Quick Check:

    7.class = Integer [OK]
Quick Trick: Integers belong to Integer class in Ruby 2.4+ [OK]
Common Mistakes:
  • Thinking Fixnum is still used in modern Ruby
  • Assuming numbers belong to generic Number class
  • Confusing Object with Integer class

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes