Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. Which of the following is supported by Ruby?
  1.    Multiple Programming Paradigms
  2.    Dynamic Type System
  3.    Automatic Memory Management
  4.    All of the Mentioned
 Discuss Question
Answer: Option D. -> All of the Mentioned


Ruby supports all the features because it is a object oriented programming language.


Question 2. Why do we use =begin and =end?
  1.    To mark the start and end of multiline comment
  2.    To comment multiple lines
  3.    To avoid the use of # again and again
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


Easier way to comment multiple lines.


Question 3. Which of the following are valid floating point literal?
  1.    5
  2.    2
  3.    0.5
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> 0.5


floating point literals are valid only when they have digits on both the sides of decimal point.


Question 4. What is the output of the given code?"Ruby.length #to find the length of given string
  1.    4 to find the length of given string
  2.    4
  3.    To find the length of given string
  4.    Ruby
 Discuss Question
Answer: Option B. -> 4


It finds the length of string.


Question 5. Why can not we use quotation marks (' or ") with boolean?
  1.    It indicates that we are talking about a string
  2.    It indicates that we are assining a value
  3.    It indicates that that we are replacing boolean data type with string data type
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> It indicates that we are talking about a string


Quotation marks are used only with strings.


Question 6. What is the output of the given code?boolean_1 = 77 less than 78puts(boolean_1)
  1.    Nil
  2.    True
  3.    False
  4.    Error
 Discuss Question
Answer: Option B. -> True


As 77 is less than 78 hence the boolean value will be printed as true.
Output:
True


Question 7. What is the output of the given code?print "Hey"   puts "Everyone!"   print "We are learning Ruby"
  1.    Error
  2.    Hey everyone we are learning Ruby
  3.    Hey everyone
  4.    Hey Everyone
 Discuss Question
Answer: Option D. -> Hey Everyone


Print prints whatever is given and puts in addition to printing it inserts a new blank line.


Question 8. What is the role of ! at the end of the capitalize method?
  1.    It is the syntax for using capitalize method
  2.    It modifies the value stored in the variable
  3.    It indicates the termination of string
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> It modifies the value stored in the variable


It is used for modifying the variable.


Question 9. Which sequence can be used to substitute the value of any ruby expression in a string?
  1.    #(expr)
  2.    #{expr}
  3.    #expr
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> #{expr}


#{expr} is valid.


Question 10. What will be the output of the following?"Eric".irreverse
  1.    Eric
  2.    cirE
  3.    undefined method
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> undefined method


There is no predefined method named irreverse in ruby.
Output:
undefined method `irreverse' for "eric":String


Latest Videos

Latest Test Papers