Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Define the main differences between nil and false in Ruby?

Answer»

Define the MAIN differences between nil and false in Ruby?
Below are the four main difference between nil and and false:-
(1)nil:-Here in ruby nil cannot be a value.
(1)false:-Here in ruby false can be treated as value.

(2)nil:-nil is not a BOOLEAN data type
(2)false:-false is a boolean data type.

(3)nil:-In ruby nil is an object of nilclass.
(3)false:-In ruby false is an object of falseclass.

(4)nil:-nil is returned where there is no predicate.
(4)false:-when there is case of predicate value of true or false is returned by a METHOD.

2.

What do you mean by redo statement in Ruby?

Answer»

What do you mean by redo STATEMENT in RUBY?
Ruby redo statement basically is used to repeat current iteration of LOOP. And when we need to execute redo statement we donot need to EVALUATE loop condition. The redo keyword can be useful in the context of a loop or an enumeration.


Redo Ruby
Output of above code is :-


Redooutput ruby

3.

How can we create a Ruby Object?

Answer»

How can we create a Ruby OBJECT?
Creating object in Ruby is very unique TYPE of method which is predefined in Ruby library. To create OBJECTS we use new method of the class. Below is the syntax for creating objects

Objectexample=Nameofclass.new

4.

Why Ruby is said as flexible language

Answer»

Why Ruby is said as FLEXIBLE language
One of the main Reason why Ruby is called language of flexibility is that it helps author to ALTER its programming elements. We can removed or redefined some specific PARTS of Ruby language. Just like we need to GET difference between two number then we can use - sign or the word 'minus'. We can do this by built-in CLASS numeric.