The Object Model Flashcards

1
Q

What is encapsulation in Object Oriented Programming?

A

Encapsulation is hiding pieces of functionality and making it unavailable to the rest of the code base. It is a form of data protection, so that data cannot be manipulated or changed without obvious intention.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is polymorphism in Object Oriented Programming?

A

Polymorphism is the ability for data to be represented as many different types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is inheritance?

A

The concept of inheritance is used in Ruby where a class inherits the behaviors of another class, referred to as the superclass. This gives Ruby programmers the power to define basic classes with large reusability and smaller subclasses for more fine-grained, detailed behaviors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Besides inheritance, what is another way to utilize polymorphism in Ruby?

A

Using modules. Modules are similar to classes in that they contain shared behavior. However, you cannot create an object with a module. A module must be mixed in with a class using the reserved word ‘include’. This is called a mixin. After mixing in a module, the behaviors declared in that module are available to the class and its objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Ruby define the attributes and behaviors of it’s objects?

A

Ruby defines the attributes and behaviors of its objects in classes. You can think of classes as basic outlines of what an object should be made of and what it should be able to do.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is instantiation?

A

This entire workflow of creating a new object or instance from a class is called instantiation.

Example:
class GoodDog
end

sparky = GoodDog.new

In the above example we can say that we’ve instantiated an object called sparky from the class GoodDog.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you see the lookup chain for a method?

A

With the ‘ancestors’ method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly