Bird
0
0

Which of the following is the correct way to print "Hello" in Ruby?

easy📝 Syntax Q12 of 15
Ruby - Basics and Runtime
Which of the following is the correct way to print "Hello" in Ruby?
Aprint("Hello")
Becho "Hello";
Cconsole.log("Hello")
Dprintf("Hello")
Step-by-Step Solution
Solution:
  1. Step 1: Identify Ruby's print syntax

    Ruby uses the method print() to show text on the screen.
  2. Step 2: Check other options for language mismatch

    echo is from PHP, console.log is JavaScript, printf is C-style but less common in Ruby for simple output.
  3. Final Answer:

    print("Hello") -> Option A
  4. Quick Check:

    Ruby print syntax = print("Hello") [OK]
Quick Trick: Ruby uses print() to show text [OK]
Common Mistakes:
  • Using echo instead of print
  • Using console.log from JavaScript
  • Confusing printf with print

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes