Ruby String MCQ

This section focuses on "String" MCQs in Ruby. These Multiple Choice Questions (MCQ) should be practiced to improve the Ruby skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.

1. StringĀ is a sequence of _________ characters.

A. one
B. many
C. Both A and B
D. None of the above

View Answer


2. String may consists of?

A. Number
B. letter
C. Special character
D. All of the above

View Answer


3. String are?

A. mutable
B. unmutable
C. Both A and B
D. None of the above

View Answer


4. Double quotes and single quotes will interpolates ?

A. TRUE
B. FALSE
C. double quotes will interpolates
D. Single quotes will interpolates

View Answer


5. What will be output for the folowing code?

str1 = "LFC" puts 'str1: #{str1}'

A. str1: LFC
B. str1: #{str1}
C. str1: {LFC}
D. str1: #{LFC}

View Answer


6. what will be output for the following code?

str1 = LFC puts "str1: #{str1}"

A. str1: LFC
B. str1: #{str1}
C. str1: {LFC}
D. str1: #{LFC}

View Answer


7. What will be output for the following code?

str2 = String.new ""LetsFindCourse""

puts str2 

A. LETSFINDCOURSE
B. letsfindcourse
C. Error
D. LetsFindCourse

View Answer


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

A. {}
B. []
C. ()
D. All of the above

View Answer


9. What will be output for the following code?

str = "LetsFindCourse Ruby MCQs" puts str[2]

A. t
B. e
C. MCQs
D. Ruby

View Answer


10. What will be output for the following code?

str = "LetsFindCourse Ruby MCQs" puts str[-2]

A. Q
B. t
C. C
D. Error

View Answer





Discussion



* You must be logged in to add comment.