Friday 6 February 2015

Ruby and Ruby on Rails Interview Questions and Answers pdf free download (Page 4)

Below are some important Ruby on Rails interview questions which are asked in most MNC company interviews for beginners or professionals.

31. How is object methods defined in Ruby? | Ruby On Rails Questions
Ans:
class jak
def method1
--------
--------
end
end

obj=jak.new
It is single object
def obj.object_method_one
--------
--------
end
obj.Send(object_method_every)
It will be created every for every object creation

32. What are the operators available in Ruby? | Ruby On Rails Questions
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 &&.

33. What are the looping structures available in Ruby? | Ruby On Rails Questions
for..in
untill..end
while..end
do..end
Note: You can also use each to iterate a array as loop not exactly like loop

34. What are the object-oriented programming features supported by Ruby? | Ruby On Rails Questions
Classes,Objects,Inheritance,Singleton methods,polymorphism(accomplished by over riding and overloading) are some oo concepts supported by ruby.

35. What is the scope of a local variable in Ruby? | Ruby On Rails Questions
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.

36. How is an iterator handled in Ruby? | Ruby On Rails Questions
Iterator is handled using keyword 'each' in ruby.
For example
number=[1,2,3]
then we can use iterator as
number.each do |i|
puts i
end
Above prints the values of an array $no which is accomplished using iterator.

37. How is visibility of methods changed in Ruby? | Ruby On Rails Questions
By applying the access modifier : Public , Private and Protected acces Modifier

38. What is the use of load and require in Ruby? | Ruby On Rails Questions
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.

39. Explain about class libraries in ruby?
Ruby has a strong set of class libraries and it covers from a variety of domains such as thread programming, domains and data types. Also ruby is a new language and it also has additional libraries coming every day. Many of the new languages which do exist have huge libraries because of their age.

40. Explain about portability?
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.
More Questions & Answers :-

No comments:

Post a Comment