CommerceBasic Syntax In Ruby MCQs
Practice Basic Syntax In Ruby MCQs for competitive exams.
Basic Syntax In Ruby MCQs
Practice questions from this topic.
How to comment a single line?
- A. Using #
- B. Using begin and end
- C. Using //
- D. None of the mentioned
Correct Answer: A
Methods should not be written inside double quotes.
- A. True
- B. False
Correct Answer: A
Which of the following datatypes are valid in Ruby?
- A. Numbers
- B. Boolean
- C. String
- D. All of the mentioned
Correct Answer: D
What does %x!ls! represents?
- A. Same as back tick command output 'ls'
- B. Same as 'x'
- C. Same as "xls"
- D. None of the mentioned
Correct Answer: A
Which sequence can be used to substitute the value of any ruby expression in a string?
- A. #(expr)
- B. #{expr}
- C. #expr
- D. None of the mentioned
Correct Answer: B
The downcase method changes the whole string to smallcase letters.
- A. True
- B. False
Correct Answer: A
The .upcase and .capitalize method are used for capitalizing the whole string.
- A. True
- B. False
Correct Answer: B
What will we the output of the given code? "I'am Learning RUBY Language".downcase
- A. iam learning ruby language
- B. i'AM lEARNING ruby lANGUAGE
- C. "i'am learning ruby language"
- D. None of the mentioned
Correct Answer: C
We use semicolon or parentheses after every print or puts statement.
- A. True
- B. False
Correct Answer: B
What is the output of given code? puts "what is your first name?" name=gets.chomp puts "what is your surname?" surname=gets.chomp
- A. Error in compilation
- B. What is your first name? xyz(enter any name) What is your surname? wtu(enter your surname)
- C. Name=xyz
- D. None of the mentioned
Correct Answer: B
Objects of which class does the integer from the range -2^30 to 2^(30-1) belong to?
- A. Bignum
- B. Octal
- C. Fixnum
- D. Binary
Correct Answer: C
What is the output of the given code? Ans=Ruby puts "#[Ans] is an oop language"
- A. Error, no output
- B. Ruby is an oop language
- C. Warning:already initialized constant Ans
- D. None of the mentioned
Correct Answer: B