Explanation: Shebang line #!/usr/bin/ruby is used to run Ruby scripts.
Dear candidates you will find MCQ questions of Ruby here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
Explanation: Shebang line #!/usr/bin/ruby is used to run Ruby scripts.
Explanation: Both 'size' and 'length' return the length of a string in Ruby.
Explanation: Blocks in Ruby are passed using do...end or curly braces {}.
Explanation: The pop method removes and returns the last element of an array.
Explanation: String interpolation is done inside double quotes with #{variable}.
Explanation: Instance variables start with the @ symbol.
Explanation: Class variables start with @@.
Explanation: The keys method returns all keys of a hash.
Explanation: Symbols are defined by prefixing with a colon (:), e.g., :name.
Explanation: The yield keyword executes the block passed to a method.