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. Why do we use comments?
a) For later use to understand the working of the program
b) It is an efficient way of programming
c) It makes easy for the third person to understand
d) All of the mentioned

View Answer

Answer: d [Reason:] It is the efficient way of programming and easy to understand.

2. Which of the following type of comments are valid in ruby?
a) Single line comments
b) Multi line comments
c) Double line comments
d) All of the mentioned

View Answer

Answer: d [Reason:] Double line comments comes under multiline comment.

3. How to comment multiple lines in ruby?
a) Using multiline comments
b) Using single line comments
c) No option to comment
d) All of the mentioned

View Answer

Answer: a [Reason:] Multiple lines can be commented using multiline comments.

4. How to comment a single line?
a) Using #
b) Using begin and end
c) Using //
d) None of the mentioned

View Answer

Answer: a [Reason:] Use # to comment single line.

5. This the right way to comment a single line.
“Ruby”.length # I’m a single line comment!
a) True
b) False

View Answer

Answer: a [Reason:] We use # in a single line comment.

6. What is the output of the given code?
“Ruby”.length #to find the length of given string
a) 4 to find the length of given string
b) 4
c) To find the length of given string
d) Ruby

View Answer

Answer: b [Reason:] It finds the length of string.

7. The following syntax is used for multiline comment.

=begin
    iam in a multi line comment
   =end

a) True
b) False

View Answer

Answer: a [Reason:] We use =begin and =end to mark the beginning and end of the comment.

8. The following is the correct way to use multiline comment.

 = begin
   # comment
   = end

a) True
b) False

View Answer

Answer: b [Reason:] No space should be given between = and begin and = or end.

9. Why do we use =begin and =end?
a) To mark the start and end of multiline comment
b) To comment multiple lines
c) To avoid the use of # again and again
d) All of the mentioned

View Answer

Answer: d [Reason:] Easier way to comment multiple lines.

10. What is the output of the given code?

"Ruby Language".length
       =begin
       calculate length
       =end

a) 13
b) 13 calculate length
c) 12
d) None of the mentioned

View Answer

Answer: a [Reason:] Calculate the length and is commented using =begin and =end.

Output:
13

11. What is the output of the given code?

"Ruby Language".length
       = begin
       calculate length
       = end

a) 13
b) 12
c) Error
d) None of the mentioned

View Answer

Answer: c [Reason:] No space between = and begin and end

Output:
Syntax error, unexpected '=', expecting $end
= begin

12. Space between 2+5 or 2 + 5 is valid but =begin and = begin is not valid.
a) True
b) False

View Answer

Answer: a [Reason:] Ruby recognizes =begin and = begin in different way.

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