Friday 6 February 2015

How do I prepare for an entry level Ruby on Rails developer (Page 3)

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

21. How do the following methods differ: @my_string.strip and @my_string.strip! ? | Ruby On Rails Questions
The strip! method modifies the variable directly. Calling strip (without the !) returns a copy of the variable with the modifications, the original variable is not altered.

22. What's the difference in scope for these two variables: @name and @@name? @name is an instance variable and @@name is a class variable

23. What is the log that has to seen to check for an error in ruby rails? | Ruby On Rails Questions
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.

24. What is the use of global variable $ in Ruby? | Ruby On Rails Questions
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.
For example: 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


25. Where does the start_tabnav gets informations for tabs rendering in ruby rail? | Ruby On Rails Questions
The main Symbol let the start_tabnav method know to look for a special MainTabnav class where all the magic happens

26. What is the Install rail package? | Ruby On Rails Questions
There are several packages that you can download and install. The prebuilt Rails installer called Install rail which currently is only for Windows
27. 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.

28. What is the use of super in ruby rails? | Ruby On Rails Questions
Ruby uses the super keyword to call the superclass implementation of the current method

29. What is the difference between nil and false in ruby? | Ruby On Rails Questions
False is a boolean datatype, Nil is not a data type it have object_id 4

30. How is class methods defined in Ruby? | Ruby On Rails Questions
A:def self.methodname
--------
--------
end
or
def classname.methodname
--------
--------
end
More Questions & Answers :-

No comments:

Post a Comment