Q. What is the output of the given code?
"Ruby Language".length
= begin
calculate length
= end

  • (A) 13
  • (B) 12
  • (C) Error
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) Error

Q. What will be the output of the given code?
"I'am learning Ruby Language".reverse.upcase.length

  • (A) 27
  • (B) egaugnal ybuR gninreal ma'I
  • (C) ERAUGNAL YBUR GNINREAL MA'I
  • (D) Undefined method 'reverse' for 27:Fixnum
πŸ’¬ Discuss
βœ… Correct Answer: (A) 27

Q. Why do we use comments?

  • (A) For later use to understand the working of the program
  • (B) It is an efficient way of programming
  • (C) It makes easy for the third person to understand
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the mentioned

Q. How to comment multiple lines in ruby?

  • (A) Using multiline comments
  • (B) Using single line comments
  • (C) No option to comment
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) Using multiline comments

Q. What will be the output of the given code?
"Come let's learn.reverse Ruby.length language".upcase

  • (A) nreal s'tel emoC 4 LANGUAGE
  • (B) Undefined error
  • (C) "COME LET'S LEARN.REVERSE RUBY.LENGTH LANGUAGE"
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) "COME LET'S LEARN.REVERSE RUBY.LENGTH LANGUAGE"

Q. What is the output of given code?
string="I'am Learning RUBY Language".downcase
string.upcase

  • (A) Undefined method
  • (B) "I'AM LEARNING RUBY LANGUAGE"
  • (C) I'am Learning RUBY Language
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) "I'AM LEARNING RUBY LANGUAGE"

Q. What is the output of the code?
print "What's your first name?"
first_name=gets.chomp
a=first_name.capitalize
first_name.capitalize!
print "What's your last name?"
last_name=gets.chomp
b=last_name.capitalize
last_name.capitalize
puts "My name is #{first_name} #{last_name}"

  • (A) Amil Jones
  • (B) What's your first name? amil What's your last name? jones My name is Amil Jones
  • (C) What's your first name? amil What's your last name? jones My name is Amil jones
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) What's your first name? amil What's your last name? jones My name is Amil Jones

Q. What is the output of the following?
ruby.reverse

  • (A) Error in compilation
  • (B) ybur
  • (C) 4
  • (D) Undefined local variable ruby
πŸ’¬ Discuss
βœ… Correct Answer: (D) Undefined local variable ruby

Q. What is the output of the given code?
print "what's your first name?"
first_name=gets.chomp
a=first_name.capitalize
"first_name.capitalize!".reverse
puts"My name is #{first_name}"

  • (A) amil jones
  • (B) What's your first name? amil My name is amil
  • (C) My name is lima
  • (D) My name is limA
πŸ’¬ Discuss
βœ… Correct Answer: (B) What's your first name? amil My name is amil

Q. What is the output of the following?
"Iam learning ruby language".length

  • (A) 26
  • (B) 23
  • (C) 20
  • (D) 18
πŸ’¬ Discuss
βœ… Correct Answer: (A) 26