How do you share methods between different parts of your code in Ruby? Can you name three strategies for doing this? Discuss the pros and cons of each.
Ruby Object Oriented Programming Interview Questions
Suppose you have a web form that allows users to upload JPG, GIF or PNG images. Before you store the images in your system, you want to convert them all to the JPG format. Design an image converter API. Sketch out all classes and interfaces that are involved.
Note: the actual code necessary to convert a JPG image to a GIF image is not the point. Just place a comment at the appropriate location where the actual conversion should occur.
Define the following object oriented concepts:
- Class, object (and the difference between the two)
- Instantiation
- Method (as opposed to, say, a C function)
- Static methods and classes
- Destructor/finalizer
- Inheritance
- Encapsulation
- Multiple inheritance (and give an example)
- Abstract class
- Interface/protocol (and different from abstract class)
- Method overriding
- Method overloading (and difference from overriding)
- Polymorphism (without resorting to examples)
- Method visibility (e.g. public/private/other)
Describe a schema (or classes) to power an online car rental system. Describe the tables and the relationships beween the tables.
Model the animal kingdom as a set of classes. Discuss the species, their behavior and properties.
Describe the singleton design pattern and how you might use it in practice.
Implement it.
Design the schema or the classes to implement a library for building card games with. This library should make it easy to build games like Rummy, Poker, Hearts, Whist etc.
Outline the implementation for two of the most important methods of the Deck class.