Question 1. What Is Ruby Programming Language?
Answer :
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. Why Ruby Is Known As A Language Of Flexibility?
Answer :
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 3. Mention What Is The Difference Between A Gem And A Plugin In Ruby?
Answer :

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 4. Mention What Is The Difference Between A Single Quote And Double Quote?
Answer :
A single-quoted strings don’t process ASCII escape codes, and they don’t do string interpolation.

Question 5. Explain About Garbage Collection Feature Of Ruby?
Answer :

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 6. What Are The Different Environment Variables Present In The Ruby?
Answer :
Following are the different environment variables present in the Ruby:






Question 7. Explain About Float, Dig And Max?
Answer :

Float class is used whenever the function changes constantly. It acts as a sub class of numeric. They represent real characters by making use of the native architecture of the double precision floating point.

Max is used whenever there is a huge need of Float.

Dig is used whenever you want to represent a float in decimal digits.

Question 8. What Is The Use Of Interpolation In Ruby?
Answer :
Interpolation is a process of inserting a string into a literal. It is a very important process in Ruby. A string can be interpolated into a literal by placing a hash (#) within {} open and close brackets.

Question 9. What Is The Use Of Global Variable $ In Ruby?
Answer :
The global variable is declared in Ruby that you can access it anywhere within the application because it has full scope in the application. The global variables are used in Ruby with $ prepend.

Question 10. What Is The Use Of Load And Require In Ruby?
Answer :
In Ruby, load and require both are used for loading the available code into the current code. In cases where loading the code required every time when changed or every times someone hits the URL, it is suggested to use ‘load’. It case of autoload, it is suggested to use ‘require’.

Question 11. What Is Rubygems In Ruby Programming Language?
Answer :
RubyGems provides a standard format for distributing ruby programs and libraries. It works as a package manager for the Ruby programming language. RubyGems is now a part of the standard library from Ruby version 1.9.

Question 12. Overview Of Ruby Programming Language?
Answer :
Ruby is a dynamic, open source programming language. It focuses on productivity and simplicity. The syntax is elegant which is natural to read and easy to write and use. The language is flexible, since it allows the developers alter freely all its parts. At will, one can remove essential parts and redefined. For instance , the symbol + can be redefined by the word ‘plus’ to one of the its classes – Numeric.
Ruby supports multiple programming paradigms, such as, functional, imperative, object oriented, relative. Dynamic memory management and dynamic type systems are additional features of Ruby.

Question 13. Explain About Ruby Code Blocks?
Answer :
Ruby code blocks form an important part of ruby and are very fun to use. With the help of this feature you can place your code between do-end and you can associate them with method invocations and you can get an impression that they are like parameters. They may appear near to a source of the code and adjacent to a method call. The code is not executed during the program execution but it is executed when the context of its appearance is met or when it enters a method.

Question 14. What Is Rails?
Answer :
Ruby on Rails is a web application framework. It is written in Ruby. Compare to other frameworks for web application, the big deal is the way Ruby on Rails does. A web application finished in days instead of weeks, it is noticed by the community. Maintenance and/or extension of messy and hard web applications is flexible with ruby rails.

Question 15. Explain About Interpolation?
Answer :
Interpolation is a very important process in Ruby. Interpolation is the process of inserting a string into a literal. There is only one way in which you can interpolate a string into a literal by placing a Hash (#) within {} open and close brackets. This refers to a new name to by referring to the copy of the original method.

Question 16. Describe Class Libraries In Ruby?
Answer :
Ruby class libraries comprise of variety of domains, such as thread programming, data types, various domains. It has additional libraries evolving day by day. The following are the domains which has relevant class libraries.

Text processing – File, String, Regexp for quick and clean text processing.

CGI Programming – There are supporting class library for CGI programming support like, data base interface, eRuby, mod_ruby for Apache, text processing classes.

Network programming – Various well-designed sockets are available in ruby for network programming.

GUI programming – Ruby/Tk and Ruby/Gtk are the classes for GUI programming

XML programming – UTF-8 text processing regular expression engine make XML programming very handy in ruby. .

Question 17. How Does Ruby Deal With Extremely Large Numbers?
Answer :
Unlike other programming languages ruby deals with extremely large numbers it doesn’t have any barriers. There is no limit on the extent of limit of number usage. Ruby performs this function with two different classes they are fixnum and bignum. Fixnum represents easily managed small numbers and bignum represents big numbers. Ruby entirely handles the functioning of these two classes which leaves a programmer to concentrate on his arithmetic operations.

Question 18. Explain The Difference Between Nil And False In Ruby?
Answer :

False is a boolean datatype 

Nil is not a data type 

Question 19. Explain The Use Of Global Variable $ In Ruby?
Answer :
If you declare one variable as global we can access any where, where as class variable visibility only in the class 

Question 20. Explain About Portability?
Answer :
Ruby language can be ported to many platforms. Ruby programs can be ported to many platforms without any modification to the source code. This feature made the language very useful and highly used by many programmers worldwide. Some of the platforms used are DOS, UNIX, WINDOWS, etc. 


Question 21. Explain About Class Variable And Global Variable?
Answer :
A class variable starts with an @@ sign which is immediately followed by upper or lower case letter. You can also put some name characters after the letters which stand to be a pure optional. A class variable can be shared among all the objects of a class. A single copy of a class variable exists for each and every given class.
To write a global variable you start the variable with a $ sign which should be followed by a name character. Ruby defines a number of global variables which also include other punctuation characters such as $_ and $-k.

Question 22. Interpolation Is A Very Important Process In Ruby, Comment?
Answer :
Inserting a string into a literal is called as interpolation. Interpolation is a very important process in Ruby. Interpolation can be done by using only one way by embedding # within {}. A new name is referred to the copy of the original name.

Question 23. Explain About Variables?
Answer :
There are four different types of variables they are local, instance, global, and class. Variables can be used in the program without any declaration and they can contain data of any type. A local variable contains lower case characters followed by name characters. Instance variable starts with a @ sign followed by name characters.

Question 24. What Is The Use Of Super In Ruby Rails?
Answer :
The function super is used to invoke the original method, searching of the method body starts in the super class of the object that was found to contain the original method. The following example depicts the same.
def url=(address)
super (address.blank? || address.starts_with?(‘http’)) ? address : http://#{address}

Question 25. Explain About Ruby Names?
Answer :
Classes, variables, methods, constants and modules can be referred by ruby names. When you want to distinguish between various names you can specify that by the first character of the name. Some of the names are used as reserve words which should not be used for any other purpose. A name can be lowercase letter, upper case letter, number, or an underscore, make sure that you follow the name by name characters.

Question 26. Explain About Normal Method Class?
Answer :
This function calls a method and it can take any number of arguments and expr. Make sure that you put an asterisk or an ampersand before the expression. Last expr argument can be declared with a hash without any braces. If you want to increase the size of the array value then make sure that you put an asterisk before expression. “::” can be used to separate the class from methods.

Question 27. Explain About Methods?
Answer :
Methods in ruby basically perform two functions, named operation and the code present in the class which does a specific function. In Ruby all your algorithms live in methods which inturn is present on objects. Ruby does not have any provision for functions. Code present in Ruby is always a method of some object. Behind the scenes ruby gives you the flexibility to work with methods as functions if you are considering working with other languages.

Question 28. Explain The Difference Between Nil And False In Ruby.
Answer :
The differences of the methods nil and false are:

nil cannot be a value, where as a false can be a value.

A method returns true or false in case of a predicate, other wise nil is returned.

false is a boolean data type, where as nil is not.

nil is an object for NilClass, where as false is an object of for FalseClass

Question 29. Explain About The Defined Operator?
Answer :
Define operator defines whether a passed expression is defined or not. If the expression is defined it returns the description string or null if the expression is not defined. If a variable is defined it gets initialized. If method_call is defined as true then method also gets defined. This is also the same case with super and yield.

Question 30. Explain About Operators In Ruby?
Answer :
Like all the modern languages Ruby supports many different operators to its credit. Most of the operators in Ruby are in fact methods due to the object oriented nature of the language. This feature gives Ruby an edge over its competitors. Semantics of these operators can be changed due to the object oriented nature of the language.

Question 31. Explain About The Command Line Options?
Answer :
Ruby`s language is executed from the command line like most of the scripting languages. Programming and behavior language environment can be controlled from the interpreter itself. Some of the commands which are used are as follows –d, -h, -e prog, -v, -T, -r lib, etc.

Question 32. Mention What Is The Difference Between Procs And Blocks?
Answer :
The difference between Procs and Blocks,

Block is just the part of the syntax of a method while proc has the characteristics of a block.

Procs are objects, blocks are not.

At most one block can appear in an argument list.

Only block is not able to be stored into a variable while Proc can.

Question 33. List Out The Few Features Of Ruby?
Answer :
Free format – You can start writing from program from any line and column.
Case sensitive – The uppercase and lowercase letters are distinct.
Comments – Anything followed by an unquoted #, to the end of the line on which it appears, is ignored by the interpreter.
Statement delimiters- Multiple statements on one line must be separated by semicolons, but they are not required at the end of a line.

Question 34. Explain How Can We Define Ruby Regular Expressions?
Answer :
Ruby regular expression is a special sequence of characters that helps you match or find other strings. A regular expression literal is a pattern between arbitrary delimiters or slashes followed by %r.

Question 35. Mention What Is The Command To Create A Migration?
Answer :
To create migration command includes
C:rubyapplication>ruby script/generate migration table_name

Question 36. How Would You Create Getter And Setter Methods In Ruby?
Answer :
Setter and getter methods in Ruby are generated with the attr_accessor method. attr_accessor is used to generate instance variables for data that’s not stored in your database column.
You can also take the long route and create them manually.

Question 37. How Does A Symbol Differ From A String?
Answer :
symbols are immutable and reusable, retaining the same object_id.
Be prepared to discuss the benefits of using symbols vs. strings, the effect on memory usage, and in which situations you would use one over the other.

Question 38. What Are The Three Levels Of Method Access Control For Classes And What Do They Signify? What Do They Imply About The Method?
Answer :
Public, protected, and private.

Public methods can be called by all objects and subclasses of the class in which they are defined in.

Protected methods are only accessible to objects within the same class.

Private methods are only accessible within the same instance.

Question 39. Explain Some Of The Looping Structures Available In Ruby?
Answer :
For loop, While loop, Until Loop.

Question 40. What Is The Difference Between A Class And A Module?
Answer :
A module cannot be subclassed or instantiated, and modules can implement mixins.




Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!