Bird
0
0

Which of the following is the correct syntax to call a parent class method with arguments in Ruby?

easy📝 Syntax Q12 of 15
Ruby - Inheritance
Which of the following is the correct syntax to call a parent class method with arguments in Ruby?
Asuper arg1, arg2
Bsuper(arg1 arg2)
Csuper[arg1, arg2]
Dsuper{arg1, arg2}
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby method call syntax

    In Ruby, method arguments are passed separated by commas without brackets unless parentheses are used.
  2. Step 2: Identify correct super usage with arguments

    The correct way is super arg1, arg2 or super(arg1, arg2). super arg1, arg2 uses the correct syntax without parentheses.
  3. Final Answer:

    super arg1, arg2 -> Option A
  4. Quick Check:

    Pass args to super with commas [OK]
Quick Trick: Pass arguments to super separated by commas [OK]
Common Mistakes:
  • Using brackets [] or braces {} instead of parentheses or commas
  • Omitting commas between arguments
  • Using incorrect syntax like super(arg1 arg2)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes