Bird
0
0

What keyword is used to define a new class in Ruby?

easy📝 Conceptual Q1 of 15
Ruby - Classes and Objects
What keyword is used to define a new class in Ruby?
Amodule
Bdef
Cfunction
Dclass
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby class declaration

    In Ruby, the keyword to start a class declaration is class.
  2. Step 2: Identify the correct keyword among options

    Options like def define methods, module defines modules, and function is not a Ruby keyword.
  3. Final Answer:

    class -> Option D
  4. Quick Check:

    Class declaration keyword = class [OK]
Quick Trick: Use 'class' keyword to start class declaration in Ruby [OK]
Common Mistakes:
  • Using 'def' instead of 'class'
  • Confusing modules with classes
  • Using 'function' which is not Ruby syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes