OO in Ruby Flashcards
In general, how do you declare a class and it’s methods?

In general, what are initializers and how do they work?

In general, how does more than one intializer work in Ruby?

What is raise in Ruby?

How does the array work with calling an intializer/constructor

In general, how would a class look with multiple arguments for the intializer?

In general, how do you use default values in Ruby initializers

How does overloading work in Ruby?

By default, what protection is data members and methods?

What is the shorthand for writing simple accessors and mutators?

how does to_s workin Ruby?

How do you make an instance in Ruby?

In general how do you invoke methods in Ruby?

How does yield work in Ruby?

How do you pass parameters to and from a code block to be used with yield?

What is the difference between (double-dots).. and (triple-dots)… in Ruby?

How do you pass multiple parameters in a code block in Ruby?

What would this code block output?

9
Explain how for loops are blocks

In the following code, what data members exist before the initializer is run


In general, how does ruby find the correct inherrited method?

With regard to inheritance, how do initializers work? How do you call the super initializer, when is it done by default, when is it not done?



For the following code, if we made super( ) the last statement in B’s initializer, what would the output be?




Explain in detail, what is happening the code below (shadowing/overriding)


In general how does Method refinement work in Ruby?

Java
class Node {
private ListItem theItem;
private Node link;
public void print(){
theItem.print();
}
Ruby
class Node
def initialize(initItem, initLink)
@theItem = initItem
@link = initLink
end
end


In the attached code, How come if we get rid of ListItem (the hierarchy) and everything works the same way still?


What is Duck Typing in Ruby?

How does the attached code work?


How do we address safety issues with Duck Typing?

What do the following code return?


How do you ask for the class of an instance or the superclass of a class?(e.g. if B is a subclass of A, and x is an instance of B)

Why can’t you create an abstract class easily (as with Java)?

What is example code to force an abstract class/self in Ruby?

How do you define a class method in Ruby?

In the attached code, what is super equivalent to?


In gerneral how do we get an abstract method in Ruby?

What do class data memebers begin with?

In general how do you define a class method in Ruby?

What is the output of the following code and why?


In general, what happens when you define a class in Ruby? What can you think of every class being?

How would you make a method apply at the class level of every class?

In general how do you add a instance varible to Class Object

What is the output of the following code and why?


Much of the time you can forget about the fact that the class object exists… but when does it give itself away?

what is example code to attach a method to a specific instance? Where would it be stored?

How does private work with Ruby?

In general, what are data members? And how are they inherited?

What does private do to a method in Ruby?

In general what is protected in Ruby?

How do you make a class private in Ruby?

In general how do Modules work in Ruby?

What is the difference between classes and modules in Ruby?

What is the specific code to use modules in Ruby?

In what instances can a module method or inherited method name be overwritten by an existing method with the same name?

What is the specific code to bring in a module form outside the soure file?

When you use require “MyModule” or require “./MyModule”, how does the namespace work?

What is the specific code for defining the GSTModule example and using it in your program?

What’s a good practice when dealing with external modules?

In general, how does the Ruby Module Comparable work?

What is the difference between Java interfaces and Ruby modules?

How do you read data from files in Ruby?

In general how do you pase data from a file in Ruby?

Specifically, how do you parse less structured files in Ruby?

Specifically, how do you read command-line args in Ruby?

What is Dynamic code generation and how does it work in Ruby?
