
The Ruby Erudite Saga Quiz
Authored by Lorenah Mbogo
Computers
University
Used 4+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
9 questions
Show all answers
1.
FILL IN THE BLANK QUESTION
1 min • 10 pts
What does this expression evaluate to?
"Cool".+("io")
Answer explanation
This is another way to concatenate Strings. The previous example actually uses syntactic sugar (a deviation from formal syntax to enhance code readability) and this example uses the strict syntax.
2.
FILL IN THE BLANK QUESTION
1 min • 10 pts
What does this expression print?
my_name = "50 Cent"
my_name = "Miley"
p my_name
Answer explanation
The my_name variable was assigned to the value "50 Cent", but then it was reassigned to the value "Miley". Once the my_name variable is reassigned to "Miley", it loses all knowledge that it used to point to "50 Cent".
3.
FILL IN THE BLANK QUESTION
3 mins • 12 pts
Define a method called silly_check() that takes a number argument and returns "The number is less than 5" if the argument is less than 5 and "The number is greater than or equal to 5" otherwise.
4.
MULTIPLE CHOICE QUESTION
1 min • 10 pts
name = "clem"
age = 32
Is this array valid?
[name, age]
Yes
No
Answer explanation
Yes, variables can be used inside of Arrays.
5.
MULTIPLE CHOICE QUESTION
1 min • 10 pts
Which of the following is the correct way to define a class called Car?
def Car/end
class Car/end
create Car/end
6.
MULTIPLE CHOICE QUESTION
1 min • 10 pts
What is an instance variable?
A variable that describes an attribute of an instance of a class and is available to all instance methods of a class.
A variable that describes an attribute of an instance of a class and is available to both instance and class methods within a class.
7.
FILL IN THE BLANK QUESTION
3 mins • 12 pts
What does the following expression print?
if "sam" == "cat"
puts "sam equals cat"
elsif "matt" == "matt"
puts "matt equals matt"
else puts "whatever"
end
Answer explanation
The elsif keyword is used to add additional logical criteria to an if statement and this expression prints "matt equals matt". In this case, the boolean condition following the if statement ("sam" == "cat") evaluates to false, so the code inside the if block is not executed. However, the boolean condition following the elsif statement evaluates to true ("matt" == "matt"), so the code inside the elsif block is executed.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?