CECS 424 
Midterm Study Guide

The numbers refer to projects.  These are not exam questions but questions will be based on them.   Illustrate each answer with examples.  One way or another examples will be the focus of the exam.  Either you write them or I write them and ask you about them.

1. a.  Explain with examples the difference between static typing in C# and dynamic 
          typing in Ruby. 
     b. Explain dynamic binding in C#.

2. a. How does the grammar in C# allow one to determine what can appear in a C# 
         program not nested inside anything else?
    b. To what Ruby class do top-level variables and methods belong?  What access 
         do they have in other Ruby classes?

3. a. What can a Ruby module contain?  What differentiates a module from a class?     
         What is the point of putting instance methods in a module?  What instance 
         methods does Comparable contain and how are they used?
    b. If a class is defined in a C# namespace, how does one instantiate that class    
        outside of that namespace?  What does that imply about reusing that class’ 
        name?
    c. How does a C# class implement the IComparable interface?

4.a. In Ruby which String method enables one to substitute one substring for
        another?  What is the significance of the ! as the last character of a method 
        name?
   b.  In C# which String method enables one to substitute one substring for
        another?  Is it the equivalent of a Ruby method with or without the !?

5. a. What does an attribute accessor declaration in Ruby provide?  How does one 
         define an attribute getter and setter where the attribute is not itself stored but is 
         computed from a stored attribute? 
    b. How are attributes used in a program?  How does this differ from methods?
    c. How does one define a property in C#?  How are properties used in a C# 
        program? How does this differ from methods?

6. a.  What is the difference between a statement and an expression?  How do 
          Ruby and C# differ in their treatment of control structures regarding 
          statements and expressions?
    b.  What determines whether a class can be used in Ruby case expressions?  

7.  Show how to define and use arrays in Ruby and hash tables in Ruby 
     and C#. 

8.  Explain the regular expression syntax.  Be able to interpret regular expressions 
     and find matches.

9.  a. A Ruby iterator is a method that can invoke a block of code.  Illustrate how that 
          works, using the yield statement.
     b. Show how the find method of the Array class could be implemented. How is 
         find used?   

10.a. Define and use Ruby methods with a variable number of parameters and with 
          a block parameter.   
      b. A block is a closure.  It remembers the context in which it was defined.  The 
          lambda method creates a Proc object from a block.  Give examples of the 
          definition and use of closures in Ruby. 

11. a. Show how an iterator method in the Ruby File class can be used to pass a 
           file to a block.
       b. Show how an iterator method in the IO class can be used to pass each line of 
           a file to a block.
       c. Give examples of exception handling in Ruby.
       d. Give an example of file use and exception handling in C#.