The Ruby Erudite Saga Quiz

The Ruby Erudite Saga Quiz

University

9 Qs

quiz-placeholder

Similar activities

AITT LAB QUIZ  4

AITT LAB QUIZ 4

University

10 Qs

TIU Quiz-10

TIU Quiz-10

University

10 Qs

Java Quiz#2(Non-static Variables)

Java Quiz#2(Non-static Variables)

University

10 Qs

OOP Review 2

OOP Review 2

University

10 Qs

object oriented programming

object oriented programming

11th Grade - University

10 Qs

Quiz 5

Quiz 5

University

11 Qs

Nested Classes + java

Nested Classes + java

University

10 Qs

5MM OOP Classes

5MM OOP Classes

University

12 Qs

The Ruby Erudite Saga Quiz

The Ruby Erudite Saga Quiz

Assessment

Quiz

Computers

University

Hard

Created by

Lorenah Mbogo

Used 4+ times

FREE Resource

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.

8.

MULTIPLE CHOICE QUESTION

3 mins • 12 pts

Consider the following code:

class Car

def initialize(name)

@name = name

end

def name=(name)

@name = name

end

def name

@name

end

end

brand = Car.new

Car.new in this example will instantiate a new instance of the Car class.

True

False

9.

FILL IN THE BLANK QUESTION

3 mins • 14 pts

Media Image

Consider the following table and SQL query:

What will the SQL query above return?