Q. String is a sequence of _________ characters.

  • (A) one
  • (B) many
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B
Explanation: string is a sequence of one or more characters

Q. String may consists of ..........

  • (A) Number
  • (B) letter
  • (C) Special character
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: String may consist of numbers, letters, or symbols.

Q. String are

  • (A) mutable
  • (B) unmutable
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) mutable
Explanation: strings are mutable, i.e. strings can be changed in place instead of creating new strings.

Q. Double quotes and single quotes will interpolates ?

  • (A) TRUE
  • (B) FALSE
  • (C) double quotes will interpolates
  • (D) Single quotes will interpolates
πŸ’¬ Discuss
βœ… Correct Answer: (C) double quotes will interpolates
Explanation: In string, double quotes will interpolates while single quotes will not interpolates.

Q. What will be output for the following code?

Code:
str1 = "LFC" puts 'str1: #{str1}'
  • (A) str1: LFC
  • (B) str1: #{str1}
  • (C) str1: {LFC}
  • (D) str1: #{LFC}
πŸ’¬ Discuss
βœ… Correct Answer: (B) str1: #{str1}
Explanation: Cannot Interpolate so output is str1: #{str1}.

Q. what will be output for the following code?

Code:
str1 = LFC puts "str1: #{str1}"
  • (A) str1: LFC
  • (B) str1: #{str1}
  • (C) str1: {LFC}
  • (D) str1: #{LFC}
πŸ’¬ Discuss
βœ… Correct Answer: (A) str1: LFC

Q. In ruby, User can access the string elements by using the__________?

  • (A) {}
  • (B) []
  • (C) ()
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) []
Explanation: User can access the string elements by using the square brackets []. In square brackets [], the user can pass the strings, ranges or indexes.

Q. Ruby arrays are ____________

  • (A) unordered
  • (B) ordered
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) ordered
Explanation: Ruby arrays are ordered, integer-indexed collections of any object.

Q. Each element in an array is associated with _______.

  • (A) Numbers
  • (B) Index
  • (C) Integer
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) Index
Explanation: Each element in an array is associated with and referred to by an index.

Q. Array indexing in ruby starts at_________.

  • (A) -1
  • (B) 1
  • (C) 0
  • (D) Random number
πŸ’¬ Discuss
βœ… Correct Answer: (C) 0
Explanation: Array indexing starts at 0, as in C or Java.