Ruby objects Flashcards
To know everything about Ruby objects
All values are objects. T/F?
true
What class do all Ruby objects inherit from?
Object
What module does the object class mix in?
The Kernel module
What does mixing in the Kernel module do to the built-in kernel functions?
it makes them globally accessible
In Ruby, objects are directly manipulated. T/F?
False. References to objects are manipulated, not the objects themselves.
Are method arguments pass by value or by reference?
by value
What values are passed to methods?
object references
Methods can use the object references to modify the underlying object. T/F?
true
What types of values are Fixnum and Symbol treated as in a typical Ruby implementation?
immediate values
What method is most often used to explicitly create an object?
new
What does the following code do?
myObject = myClass.new
It creates a new object called myObject of type myClass.
What class does the method new belong to?
Class
What method method is invoked to initialize a new object?
initialize
What are factory methods?
They are methods that allows you to initialize an object in different ways.
What does the class method do?
It returns an object representing the class.
Example:
o = “test” # This is a value
o.class # Returns an object representing the String class
What does the following code return?
a = 3.2
puts a.class.superclass
Numeric
What class is the true root of the class hierarchy in Ruby 1.9?
BasicObject
What method can be used to determine what class an object belongs to?
instance_of?
What two methods are used to determine if an object is subclass of a class?
is_a?
kind_of?
What operator can be used in place of the is_a? method?
===
Define: object type
the set of behaviors that characterize the object or the set of methods it can respond to
What method is used to determine if a method can be invoked on an object?
respond_to?
What class enabled reading from and writing to string objects as if they were IO objects?
StringIO
What does the equal? method test?
Whether two values refer to exactly the same object.