By Convention, a Ruby Method Name That Ends in ? Is Assumed to Return a Boolean (True/False)

By Convention, a Ruby Method Name That Ends in ? Is Assumed to Return a Boolean (True/False)

Help

By convention, a Ruby method name that ends in ? is assumed to return a boolean (true/false) value.

TRUE OR FALSE

In Ruby, programs are first compiled into an executable form and then executed with a second command.

TRUE OR FALSE

In Ruby, the first line of executed code will ALWAYS be the first line of code found inside the function: def main( ARGV )

TRUE or FALSE

In Ruby, program statements all need to end with a ;

TRUE or FALSE

When the following pile of Ruby program is invoked with the command:
ruby test.rb A B C College
one, two, three = ARGV

the value of the variable one will be

  1. A
  2. B
  3. College
  4. A B College

In Ruby, by convention, local variables

Select one:

a. start with a lower case letter and are made up of letters, numbers and underscore.

b. start with a $ and are made up of letters, numbers and underscore. <- Global variables

c. start with a @ and are made up of letters, numbers and underscore. <- Instance variables

d. start with a @@ and are made up of letters, numbers and underscore. <- Class variables

e. Ruby local variables may start with any of the choices listed here.

In Ruby, by convention, the instance variables of a class

Select one:

a. start with a lower case letter and are made up of letters, numbers and underscore. <- Local variables

b. start with a $ and are made up of letters, numbers and underscore. <- Global variables

c. start with a @ and are made up of letters, numbers and underscore.

d. start with a @@ and are made up of letters, numbers and underscore. <- Class variables

e. Ruby instance variables of a class may start with any of the choices listed here.

In Ruby, datatypes such as Integer, Float and String are examples of

Select one:

a. methods

b. classes

c. objects

d. operators

In Ruby, gets, puts and print are examples of

Select one:

a. methods

b. classes

c. objects

d. operators

In Ruby, declared variables are examples of

Select one:

a. methods

b. classes

c. objects

d. operators

When the following pile of Ruby program is invoked with the command:
ruby test.rb A B College

the value of the variable $0 will be

Select one:

a. A

b. B

c. College

d. A B College

e. test.rb

All of the following piles of Ruby code build an array that holds the values:

iPhone 5
iPhone 5S
iPhone 6
iPhone 6 Plus

EXCEPT

Select one:

a. phones = ["iPhone 5", "iPhone 5S", "iPhone 6", "iPhone 6Plus"]

b. phones = ['iPhone 5', 'iPhone 5S', 'iPhone 6', 'iPhone 6Plus']

c. phones = Array[ ]
phones < "iPhone 5" < "iPhone 5S" < "iPhone 6" < "iPhone 6Plus"

d. phones = %w[ "iPhone 5" "iPhone 5S" "iPhone 6" "iPhone 6Plus" ]

e. All of the choices above build the array that was requested.

When the Ruby interpreter finds syntax errors with your program, it uses what keyboard symbol to report where it thinks the error is located?

Select one:

a. ^

b. !

c. <

d. >

In Ruby, the reason much of our code said:

name = gets.chomp

is because

Select one:

a. By default, gets returns a string whose last character will be the ending newline the user typed.

b. Ruby requires all numerical values to be chomp'ed.

c. gets won't execute without being told to chomp a value.

d. None of the choices listed here are correct.

e. All of the choices listed here are correct.

All of the following piles of Ruby code get the value:

RS89 \ Ruby!

into the variable s EXCEPT

Select one:

a. s = <TEST
RS89 \\ Ruby!
TEST

b. s = " RS89 \\ Ruby!"

c. s = ' RS89 \\ Ruby!'

d. All of the choices above get the value: RS89 \ Ruby! into the variable s

e. None of the choices above get the value: RS89 \ Ruby! into the variable s

When Ruby code raise's an exception, the exception gets handled by a block of code identified by

Select one:

a. the rescue clause.

b. the catch clause.

c. the handle clause.

d. the exception clause.

For the Ruby function defined below:

def exam( a = 1, b = 2, c = a+b )

a * b * c

end

the value 30 is returned from all of the following function calls EXCEPT

Select one:

a. exam

b. exam 3

c. exam 3, 2, 5

d. exam 6, 1, 5

e. The value 30 is returned from all the functions calls listed here.

For the Ruby function defined below:

def callit( x, y="Hello", z=1 )

# some code goes here...

end

all of the following are successful ways to call the function above EXCEPT

Select one:

a. callit

b. callit 1, 2

c. callit 1, 2, 3

d. callit 1

e. All of the function calls listed here will succesfully call the callit function

All of the following piles of Ruby program print the message: Los Angeles Dodgers EXCEPT for

Select one:

a. name = "Los Angeles Dodgers"
puts "#{name}"

b. name = 'Los Angeles Dodgers'
puts "#{name}"

c. name = 'Los Angeles Dodgers'
puts '#{name}'

d. All of the choices shown here prints the message: Los Angeles Dodgers

In Ruby, which of the following functions can be used to calculate the product of two numbers?

Select one:

a. def multiply( a , b )

product = a * b

return( product )
end

b. def multiply( a , b )

product = a * b
end

c. def multiply( a , b )

a * b
end

d. All of the functions shown here correctly return the calculated product of two numbers.

e. None of the functions shown here correctly return the calculated product of two numbers.