Ruby On Rails Interview Questions and Answers
Ques 6. What is a class?
Ans. You should easily be able to explain not only what a class is, but how and when you would create a new one as well as what functionality it would provide in the larger context of your program.
Ques 7. What is the difference between a class and a module?Ans. The straightforward answer: A module cannot be subclassed or instantiated, and modules can implement mixins.
Ques 8. What is an object?Ans. Textbook answer here is that an object is an instance of a class and has state, behavior, and identity. In a plain text example, you can say that a truck and a car are both objects of the class Vehicle, or that apple and pear are both objects of the class Fruit.
Ques 9. How would you declare and use a constructor in Ruby?Ans. Constructors are declared via the initialize method and get called when you call on a new object to be created.
Ques 10. How does a symbol differ from a string?Ans. Symbols are immutable and reusable, retaining the same object_id.
Most helpful rated by users: