Bird
0
0

Which of the following is true about numbers in Ruby?

easy📝 Conceptual Q2 of 15
Ruby - Basics and Runtime
Which of the following is true about numbers in Ruby?
ANumbers are primitive types, not objects
BNumbers are stored as strings internally
CNumbers cannot have methods called on them
DNumbers are objects and have methods
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby's treatment of numbers

    In Ruby, numbers like integers and floats are objects, so they have methods you can call on them.
  2. Step 2: Evaluate the options

    Numbers are objects and have methods correctly states that numbers are objects and have methods, which is true in Ruby.
  3. Final Answer:

    Numbers are objects and have methods -> Option D
  4. Quick Check:

    Numbers in Ruby = Objects with methods [OK]
Quick Trick: Numbers in Ruby behave like objects with methods [OK]
Common Mistakes:
  • Assuming numbers are primitive and lack methods
  • Thinking numbers are stored as strings
  • Believing numbers cannot respond to methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes