Bird
0
0

Which of these is a correct single-line comment in Ruby?

easy📝 Conceptual Q2 of 15
Ruby - Basics and Runtime
Which of these is a correct single-line comment in Ruby?
A// This is a comment
B<!-- This is a comment -->
C/* This is a comment */
D# This is a comment
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby comment syntax

    Ruby uses the # symbol to start single-line comments.
  2. Step 2: Match the correct option

    Only # This is a comment uses # correctly for a single-line comment.
  3. Final Answer:

    # This is a comment -> Option D
  4. Quick Check:

    Single-line comment symbol = # [OK]
Quick Trick: Use # for single-line comments in Ruby [OK]
Common Mistakes:
  • Using // from other languages
  • Using /* */ which is not Ruby
  • Confusing HTML comments with Ruby

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes