- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
Ruby Interview Questions & Answers - Learning Mode

Ruby Interview Questions & Answers - Learning Mode

Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. Ruby is a programming language. It was created 20 years ago by Yukihiro ?Matz? Matsumoto. By most measures of programming language popularity, Ruby ranks among the top ten, though usually as tenth (or so) in popularity, and largely due to the popularity of Rails.

Try Ruby Interview Questions & Answers - Exam Mode

1 2 Next

Sort By : Latest First | Oldest First | By Rating

Ruby Interview Questions & Answers - Learning Mode
Try Ruby Interview Questions & Answers - Exam Mode
Question: 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. Source:
Question: How do you write to STDOUT in Ruby?

Answer: Actually two methods are available:
puts writes with a newline
print writes without a newline
Question: What is the use of Destructive Method?

Answer: In ruby, we conventionally attach '!' or '?' to the end of certain method names. The exclamation point (!, sometimes pronounced aloud as "bang!") indicates something potentially destructive, that is to say, something that can change the value of what it touches.?chop!?affects a string directly, but?chop?with no exclamation point works on a copy. Here is an illustration of the difference.
s1 = "forth"
Question: 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. Source:
Question: What?s the difference in scope for these two variables: @name and @@name?

Answer: @name is an instance variable and @@name is a class variable Source:
Question: 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. Source:
Question: 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. Source:
Question: What is the Notation used for denoting class variables in Ruby?

Answer: 1) a constant begins with an uppercase letter and it should not be defined inside a method
2) a local must begin with a lowercase letter or the _ underscore sign
3) a global begins with the $ sign; an uninitialized global has the value of "nil" and also produces a warning. can be reffered anywhere in the program
4) instances begin with the @ sign; an uninitialized instance has the value of "nil" and also produces a warning
5) a class variable begins with double @@ and have to be firs Source:
Question: 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. Source:
Question: 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. Source:
Question: 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. Source:
Question: What is ruby?

Answer: No answer available currently.
Question: 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. Source:
Question: 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. Source:
Question: How do the following methods differ: @my_string.strip and @my_string.strip! ?

Answer: 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. Source:
Question: What two delimiters are used for blocks?

Answer: Curly braces {?} and ?do???end?
Bonus: coding convention is to use curly braces if the code will fit on one line and ?do???end? syntax if the block contains multiple lines.
Question: Explain about garbage collection feature of ruby?

Answer: Ruby is an object oriented language and every object oriented language tends to allocate many objects during execution of the program. Ruby deletes unallocated and unused objects automatically. This feature can be controlled by applying proper syntax and program through ruby. Source:
Question: What is the use of load and require in Ruby?

Answer: require 'rake'

will cause ruby to look for one of the files rake.rb or in the
directories listed in $:. The script in bin is called simply rake, not
rake.rb, and so require doesn't even consider it.

load, instead, interpret its argument in a different way: it considers
it to
be the whole basename of the file and doesn't try to add any extension
to it.
So, the line

load 'rake'

will make ruby look for a file called  Source:
Question: 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. Source:
Question: How do you capitalize all characters in a string?

Answer: ?this is my string?.upcase
If the string is in a variable:
Note: The method: upcase! is another alternative. See next question regarding methods that end with an exclamation.

1 2 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.046875 Seconds