To Lecture Notes

IT 231 -- 10/2/12

 

Review Questions

  1. Explain the difference between a class and an object.
    Ans: An object has instance variables that contain data and methods that can be executed. A class defines the behavior of the objects. Here is the miller analogy:
    class : object :: cookie cutter : cookie
     
  2. What is the dot operator?
    Ans: The dot operator executes a method that belongs to the class or object on its left.
     
  3. What is the difference between a class method and an object method? Give an example of each.
    Ans: A class method must be called using the class name; an object method must be called by an object. For example, in t = Time.now, now is an object method called by the class Time. In t.day, day is an object method that tells the current day for the object t.
     
  4. Test these String class methods:
  5. Choose four Fixnum class methods and write a Ruby script to test them.

 

Project 3

 

Some ActiveRecord Method Calls

 

Project 3

 

Modifying Ruby Code for IO

 

Control Structures