CommerceBasic Syntax In Ruby MCQs
Practice Basic Syntax In Ruby MCQs for competitive exams.
Basic Syntax In Ruby MCQs
Practice questions from this topic.
Ruby can deal with both numbers and floating point values.
- A. True
- B. False
Correct Answer: A
What is the output of the given code? boolean_1 = 77<78 puts(boolean_1)
- A. Nil
- B. True
- C. False
- D. Error
Correct Answer: B
What is the output of the given code? print "what's your first name?" first_name=gets.chomp a=first_name.capitalize "a".reverse puts"My name is #{a}"
- A. amil jones
- B. What's your first name? amil My name is Amil
- C. My name is lima
- D. My name is limA
Correct Answer: B
Which of the following is not a valid library function?
- A. Puts
- B. Print
- C. Gets
- D. Get
Correct Answer: D
What is the output of the given code? “Ruby”.length #to find the length of given string
- A. 4 to find the length of given string
- B. 4
- C. To find the length of given string
- D. Ruby
Correct Answer: B
What is the output of the given code? my_string=Ruby puts(my_string)
- A. Ruby
- B. Nil
- C. Error
- D. None of the mentioned
Correct Answer: C
What do we mean by expression substitution?
- A. Embedding the value of Ruby expression into a string using #{ }
- B. Substituting string functions
- C. Storing string value
- D. None of the mentioned
Correct Answer: A
What is the output of the given code? print "What's your address" city,state,pin=gets.chomp,gets.chomp,gets.chomp puts "Iam from #{city} city, #{state} state, pincode: #{pin} "
- A. Error in compilation
- B. Give your address
- C. What's your address? Chennai Tamilnadu 600048 Iam from Chennai city, Tamilnadu state, pincode: 600048
- D. None of the mentioned
Correct Answer: C
Ruby can be embedded into Hypertext Markup Language(HTML).
- A. True
- B. False
Correct Answer: A
What is the output of the given code? print "Hey" puts "Everyone!" print "We are learning Ruby"
- A. Error
- B. Hey everyone we are learning Ruby
- C. Hey everyone
- D. Hey Everyone We are learning Ruby
Correct Answer: D
What does %Q{ Learn ruby language } represents?
- A. " Learn Ruby language "
- B. "%{ Learn Ruby language }"
- C. " learn ruby language "
- D. None of the mentioned
Correct Answer: A
What is the output of the the given code? puts "My name is #{Name}"
- A. Error in compilation
- B. Name variable not defined earlier
- C. My name is #{Name}
- D. Undefined Error
Correct Answer: B