Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Which of the following is the valid string method?
a) The .length method
b) The .upcase method
c) The .downcase method
d) The .irreverse method

View Answer

Answer: d [Reason:] There is no predefined method which can reverse an already reversed string.

2. The .length method is used to check number of characters.
a) True
b) False

View Answer

Answer: b [Reason:] The .length method is used to check number of characters, spaces and even symbols.

3. What is the output of the following?

 "Iam learning ruby language".length

a) 26
b) 23
c) 20
d) 18

View Answer

Answer: a [Reason:] It checks the number of blanks, number of characters and symbols in the given string.

Output:
26

4. What is the output of the following?

 ruby.reverse

a) Error in compilation
b) ybur
c) 4
d) Undefined local variable ruby

View Answer

Answer: d [Reason:] String should always be in double quotes and then the .reverse method can be used.

Output:
undefined local variable or method `ruby' for #<Context:0x7420ac>

5. What will be the output of the following?

"Eric".irreverse

a) Eric
b) cirE
c) undefined method
d) None of the mentioned

View Answer

Answer: c [Reason:] There is no predefined method named irreverse in ruby.

Output:
undefined method `irreverse' for "eric":String

6. What does the .upcase method do?
a) Convert the string to uppercase
b) Convert only lowercase string to uppercase and vice-versa
c) Convert the string to lowercase
d) None o the mentioned

View Answer

Answer: a [Reason:] .upcase method is used to change the given string to uppercase.

7. What will be the output of the following?

"Ruby".reverse.upcase

a) RUBY
b) ybuR
c) YBUR
d) YBUr

View Answer

Answer: c [Reason:] First the given string is reversed and then .upcase method is used to capitalize it.

Output:
"YBUR"

8. What will be the output of the given code?

"I'am learning Ruby Language".length.reverse.upcase

a) 27
b) egaugnal ybuR gninreal ma’I
c) ERAUGNAL YBUR GNINREAL MA’I
d) Undefined method `reverse’ for 27:Fixnum

View Answer

Answer: d [Reason:] The .length method finds the length which is a number and can’t be reversed.

Output:
undefined method `reverse' for 27:Fixnum

9. 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

View Answer

Answer: a [Reason:] The .reverse will reverse it then .upcase will capitalize it and .length method give the length.

Output:
27

10. The downcase method changes the whole string to smallcase letters.
a) True
b) False

View Answer

Answer: a [Reason:] Changes everything to smallcase.

11. 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

View Answer

Answer: c [Reason:] Everything is changed to smallcase because of downcase method is used.

Output:
"i'am learning ruby language"

12. 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

View Answer

Answer: b [Reason:] First the given string is changed to uppercase and stored in variable named string and then the string is changed to uppercase.

Output:
"I'AM LEARNING RUBY LANGUAGE"

13. 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

View Answer

Answer: c [Reason:] Methods are never written inside double quotes.

Output:
"COME LET'S LEARN.REVERSE RUBY.LENGTH LANGUAGE"

14. 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) unterminated string meets end of file

View Answer

Answer: d [Reason:] Strings should be in double quotes in Ruby language.

Output:
Unterminated string meets end of file

15. Methods should not be written inside double quotes.
a) True
b) False

View Answer

Answer: a [Reason:] Always make sure to write methods outside double quotes.

Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com