Quiz Stuff

Quiz 7, February 26, 2018
3 minutes; ½ point each; 2.5 points total

  1. What is the most significant difference between Java and Ruby's string data types?
  2. What's the difference between an applicative and an imperative method?
  3. Ruby has a rich set of operations for accessing characters in a string.
    Given s="testing", show two distinctly different expressions
    of the form s[...] and the value produced by each.
  4. Write a Ruby expression whose value is nil.
  5. Tell me something about Ruby other than evidenced in the questions above and below. (+½ point for a good one!)

EC 1 ½ point: In the terminology of Ruby, what is the "receiver"?

EC 2 ½ point: Within ten days, what day of the year is Ruby's birthday?

Answers

  1. What is the most significant difference between Java and Ruby's string data types?
    Ruby strings are mutable.
  2. What's the difference between an applicative and an imperative method?
    Imperative methods modify the value of the receiver.
  3. Ruby has a rich set of operations for accessing characters in a string.
    Given s="testing", show two distinctly different expressions
    of the form s[...] and the value produced by each.
    s[0] => "t", s[0,4] => "test"
  4. Write a Ruby expression whose value is nil.
    nil is good enough. ""[0] works, too.
  5. Tell me something about Ruby other than evidenced in the questions above and below. (+½ point for a good one!)

EC 1 ½ point: In the terminology of Ruby, what is the "receiver"?

The object on which a method is invoked, like s in s.size.

EC 2 ½ point: Within ten days, what day of the year is Ruby's birthday?

February 24