-
-
Save rozer007/7adfc96c4fab98723e11ad36f22cfa82 to your computer and use it in GitHub Desktop.
Strings and its method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What are Strings in ruby? | |
ans: Just like all other language , even in ruby string are the collection or group of character. | |
Q2) Are String mutable in ruby? | |
ans: Yes , string are mutable in ruby. | |
Q3) What is the function to find the size of the string? | |
ans: String_name.size() | |
Q4) How to convert string to integer ? | |
ans. String_name.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1) What will in this str variable after this operation => str = "Billy" + " Bob" | |
a) billybob | |
b) Billybob | |
c) Billy + Bob | |
d) BillyBob | |
ans:d) BillyBob | |
Q2) What will be the output of this statement. | |
str="pepcoder happy coding" | |
puts str.index("hap"); | |
a) 12 | |
b) 9 | |
c) 2 | |
d) 8 | |
ans: b) 9 | |
Q3) What function is use to check whether a particular string is included in the string ? | |
a) index() | |
b) include?() | |
c) start_with?() | |
d) chomp() | |
ans: b) include?() | |
Q4) What is the output od this statement | |
str="pepcoder happy coding" | |
puts str.count("^aeiou"); | |
a) 15 | |
b) 6 | |
c) 1 | |
d) 12 | |
ans: a)15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment