|
|
|
The General Ruby Interview Questions consists the most frequently asked
questions in Ruby. This list of 100+ questions guage your familiarity with the
Ruby. The q&a have been collected over a period of time from various blogs,
forums and other sites
|
2. Ruby Core Interview Questions and FAQs
|
| 3.1 What
is the log that has to seen to check for an error in ruby rails?
|
| 3.2 What
are the looping structures available in Ruby?
|
| 3.3 What
is the difference between nil and false in ruby?
|
| 3.4 What
is the function used to build tabbed navigation in ruby rail?
|
| 3.5 What
is the scope of a local variable in Ruby?
|
| 3.6 What
is the use of global variable $ in Ruby?
|
| 3.7What
is the use of load and require in Ruby?
|
| 3.8 What
are the object-oriented programming features ?
|
| 3.9 What
are the operating systems supported by Ruby?
|
| 3.10
How is an iterator handled in Ruby?
|
| 3.11
What is the scope of a local variable in Ruby?
|
| 3.12What
are the operators available in Ruby?
|
| 3.13
How is class methods defined in Ruby?
|
| 3.14What
is the log that has to seen to check for an error in ruby rails?
|
| 3.15
What function converts all HTML special symbols to HTML entities in ruby?
|
| 3.16
What is the notation used for denoting class variable?
|
3.1 What is the log that has to seen to check for an error in ruby rails?
|
|
Rails will report errors from Apache in log/apache.log and errors from the Ruby
code in log/development.log. If you're having a problem, do have a look at what
these logs are saying. On Unix and Mac OS X you may run tail -f
log/development.log in a separate terminal to monitor your application's
execution.
|
3.2 What are the looping structures available in Ruby?
|
|
he looping structures available in Ruby are for..in untill..end while..end
do..end
|
3.3 What is the difference between nil and false in ruby?
|
|
False is a boolean datatype
Nil is not a data type
|
|
3.4 What is the function used to build tabbed navigation in ruby rail?
|
|
Tabnav it's so far the easiest way to build tabbed navigation .
|
3.5 What is the scope of a local variable in Ruby?
|
|
A new scope for a local variable is introduced in the toplevel, a class
(module) definition, a method defintion. In a procedure block a new scope is
introduced but you can access to a local variable outside the block. The scope
in a block is special because a local variable should be localized in Thread
and Proc objects. while, until, and for are control structures and the scope is
shared with the outside of these structures. loop is a method and the appended
block introduces a new scope.
|
3.6 What is the use of global variable $ in Ruby?
|
|
If you declare one variable as global we can access any where, where as class
variable visibility only in the class Example
class Test
def h
 $a = 5
 @b = 4
Â
while $a > 0
puts $a
$a= $a - 1
end
end
end
test = Test.new
test.h
puts $a                    # 5
puts @b                   #nil
|
3.7 What is the use of load and require in Ruby?
|
|
A method that loads and processes the Ruby code from a separate file, including
whatever classes, modules, methods, and constants are in that file into the
current scope. load is similar, but rather than performing the inclusion
operation once, it reprocesses the code every time load is called.
|
3.8 What are the object-oriented programming features ?
|
|
Classes,Objects,Inheritance,Singleton methods,polymorphism(accomplished by over
riding and overloading) are some oo concepts supported by ruby.
|
3.9 What are the operating systems supported by Ruby?
|
|
Ruby is supported by windows and linux.
|
3.10 How is an iterator handled in Ruby?
|
|
Iterator is handled using keyword 'each' in ruby. For example
$no=[1,2,3]
then we can use iterator as
$no.each do |l|
puts l
end
Above prints the values of an array $no which is accomplished using iterator.
|
3.11 What is the scope of a local variable in Ruby?
|
|
A new scope for a local variable is introduced in the toplevel, a class
(module) definition, a method defintion. In a procedure block a new scope is
introduced but you can access to a local variable outside the block. The scope
in a block is special because a local variable should be localized in Thread
and Proc objects. while, until, and for are control structures and the scope is
shared with the outside of these structures. loop is a method and the appended
block introduces a new scope.
|
3.12 What are the operators available in Ruby?
|
|
Something that’s used in an expression to manipulate objects such as +
(plus), - (minus), * (multiply), and / (divide). You can also use operators to
do comparisons,such as with <, >, and &&.
|
3.13 How is class methods defined in Ruby?
|
|
Class methods is defined in Ruby as def classname.methodname
|
3.14 What is the log that has to seen to check for an error in ruby rails?
|
|
Rails will report errors from Apache in log/apache.log and errors from the Ruby
code in log/development.log. If you're having a problem, do have a look at what
these logs are saying. On Unix and Mac OS X you may run tail -f
log/development.log in a separate terminal to monitor your application's
execution.
|
3.15 what function converts all HTML special symbols to HTML entities in ruby?
|
|
This function ae_some_html converts all HTML special symbols to HTML entities
|
3.16 What is the notation used for denoting class variable?
|
|
Class variable's are preceeded by @@ symbols.
|
|