• +91 9723535972
  • info@interviewmaterial.com

Ruby Interview Questions and Answers

Ruby Interview Questions and Answers

Question - 21 : - Explain while loop in Ruby.

Answer - 21 : -

Ruby while loop is used to iterate a program several times. If the number of iterations is not fixed

for a program, while loop is used.

Question - 22 : - Explain for loop in Ruby.

Answer - 22 : -

Ruby for loop iterates over a specific range of numbers. Hence, for loop is used if a program has fixed number of itrerations.

Ruby for loop will execute once for each element in expression.

Question - 23 : - Explain case statement in Ruby.

Answer - 23 : -

In Ruby, we use 'case' instead of 'switch' and 'when' instead of 'case'. The case statement matches one statement with multiple conditions just like a switch statement in other languages.

Question - 24 : - Explain Ruby data types.

Answer - 24 : -

Ruby data types represent type of data such as text, string, numbers, etc.

There are different data types in Ruby:

  • Numbers
  • Strings
  • Symbols
  • Hashes
  • Arrays
  • Booleans

Question - 25 : - Explain Ruby if-else statement.

Answer - 25 : -

The Ruby if-else statement is used to test condition. There are various types of statement in Ruby.

  • if statement
  • if-else statement
  • if-else-if (elsif) statement
  • ternary statement

Question - 26 : - Explain About Portability?

Answer - 26 : -

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. 

Question - 27 : - Explain The Use Of Global Variable $ In Ruby?

Answer - 27 : -

If you declare one variable as global we can access any where, where as class variable visibility only in the class 

Question - 28 : - Explain The Difference Between Nil And False In Ruby?

Answer - 28 : -

  • False is a boolean datatype 
  • Nil is not a data type 

Question - 29 : - How Does Ruby Deal With Extremely Large Numbers?

Answer - 29 : -

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.

Question - 30 : - Describe Class Libraries In Ruby?

Answer - 30 : -

Ruby class libraries comprise of variety of domains, such as thread programming, data types, various domains. It has additional libraries evolving day by day. The following are the domains which has relevant class libraries.

  • Text processing - File, String, Regexp for quick and clean text processing.
  • CGI Programming - There are supporting class library for CGI programming support like, data base interface, eRuby, mod_ruby for Apache, text processing classes.
  • Network programming – Various well-designed sockets are available in ruby for network programming.
  • GUI programming – Ruby/Tk and Ruby/Gtk are the classes for GUI programming
  • XML programming – UTF-8 text processing regular expression engine make XML programming very handy in ruby. .


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners