0
0
Rubyprogramming~20 mins

What is Ruby - Practice Questions & Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Ruby Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is Ruby primarily used for?

Ruby is a popular programming language. What is its main use?

ABuilding web applications and scripting
BDesigning hardware circuits
CCreating operating systems
DEditing videos and images
Attempts:
2 left
💡 Hint

Think about what Ruby is famous for in software development.

Predict Output
intermediate
1:00remaining
What is the output of this Ruby code?

Look at the Ruby code below. What will it print?

Ruby
puts 'Hello, Ruby!'
AHello, Ruby!
Bhello, ruby!
CHELLO, RUBY!
DError: undefined method 'puts'
Attempts:
2 left
💡 Hint

Remember Ruby is case-sensitive and 'puts' prints exactly what is inside the quotes.

Predict Output
advanced
1:30remaining
What is the output of this Ruby method call?

Consider this Ruby code. What will it output?

Ruby
def greet(name = 'friend')
  "Hello, #{name}!"
end

puts greet
puts greet('Alice')
AError: wrong number of arguments
B
Hello, !
Hello, Alice!
C
Hello, friend!
Hello, friend!
D
Hello, friend!
Hello, Alice!
Attempts:
2 left
💡 Hint

Look at the default parameter in the method definition.

🔧 Debug
advanced
1:00remaining
What error does this Ruby code raise?

Look at this Ruby code snippet. What error will it cause?

Ruby
arr = [1, 2, 3]
puts arr[5]
AIndexError
Bnil
CTypeError
DNoMethodError
Attempts:
2 left
💡 Hint

What happens when you access an array index that does not exist in Ruby?

🧠 Conceptual
expert
2:00remaining
Which feature is unique to Ruby compared to many other languages?

Ruby has many features. Which one below is a unique characteristic of Ruby?

ADoes not support object-oriented programming
BUses curly braces for blocks instead of do-end
CEverything is an object, even numbers and classes
DRequires explicit type declarations for variables
Attempts:
2 left
💡 Hint

Think about how Ruby treats data and code elements.