Ruby Interview Questions and Answers
Question - 1 : - What Is Ruby Programming Language?
Answer - 1 : -
Ruby is a dynamic, reflective, general purpose, open source programming language that focuses on simplicity and productivity. Ruby has a mixed features of Perl, small talk, Eiffel, Ada and Lisp. Ruby was designed to create a new language which makes a balance with the functionality of Imperative languages.
Question - 2 : - Who is the developer of Ruby?
Answer - 2 : -
Ruby is designed and developed by Yukihiro "martz" Matsumoto in mid 1990 in Japan.
Question - 3 : - Why Ruby Is Known As A Language Of Flexibility?
Answer - 3 : -
Ruby is known as a language of flexibility because it facilitates its author to alter the programming elements. Some specific parts of the language can be removed or redefined. Ruby does not restrict the user. For example, to add two numbers, Ruby allows to use + sign or the word 'plus'. This alteration can be done with Ruby's built-in class Numeric.
Question - 4 : - Mention What Is The Difference Between A Gem And A Plugin In Ruby?
Answer - 4 : -
- Gem: A gem is a just ruby code. It is installed on a machine, and it’s available for all ruby applications running on that machine.
- Plugin: Plugin is also ruby code, but it is installed in the application folder and only available for that specific application.
Question - 5 : - Mention What Is The Difference Between A Single Quote And Double Quote?
Answer - 5 : -
A single-quoted strings don’t process ASCII escape codes, and they don’t do string interpolation.
Question - 6 : - Explain About Garbage Collection Feature Of Ruby?
Answer - 6 : -
- Garbage collection is a process of reclaiming the memory space. Ruby deletes unallocated and unused objects automatically. This feature can be controlled by applying proper syntax and program through ruby.
- Ruby performs garbage collection automatically. Ruby is an object oriented language and every object oriented language tends to allocate many objects during execution of the program.
Question - 7 : - List some features of Ruby?
Answer - 7 : -
Ruby has many features. Some of them are listed below.
- Object-oriented
- Flexible
- Dynamic typing and Duck typing
- Garbage collector
- Keyword arguments
Question - 8 : - Explain some differences between Ruby and Python.
Answer - 8 : -
Similarities:
- High level language
- Support multiple platforms
- Use interactive prompt called irb
- Server side scripting language
Differences:
- Ruby is fully object oriented while Python is not.
- Ruby supports EclipseIDE while Python supports multiple IDEs.
- Ruby use Mixins while Python doesn't.
- Ruby supports blocks, procs and lambdas while Python doesn't.
Question - 9 : - What are class libraries in Ruby?
Answer - 9 : -
Ruby class libraries contain variety of domain such as thread programming, data types, various domains. Following is a list of domains which has relevant class libraries:
- Text processing
- CGI Programming
- Network programming
- GUI programming
- XML programming
Question - 10 : - Name some operators used in Ruby.
Answer - 10 : -
Operators are a symbol which is used to perform different operations.
- Unary operator
- Airthmetic operator
- Bitwise operator
- Logical operator
- Ternary operator