The elsif conditional statement is written with an expression.
True
False
View Answer
Correct Answer: A — True
Explanation:
The syntax of elsif conditional statement is elsif with an expression.
Browse topic-based Ruby practice sets.
96 practice sets · Page 3 of 5
The elsif conditional statement is written with an expression.
True
False
Correct Answer: A — True
Explanation:
The syntax of elsif conditional statement is elsif with an expression.
Which of the following is valid conditional statement in Ruby?
elseif
elsif
else if
elseiff
Correct Answer: B — elsif
Explanation:
We use elsif conditional statement in Ruby.
What does the 1..10 indicate?
Inclusive range
Exclusive range
Both inclusive and exclusive range
None of the mentioned
Correct Answer: A — Inclusive range
Explanation:
1..10 means start from one and go till 9 and even include 10.
What does the 1...10 indicate?
Inclusive range
Exclusive range
Both inclusive and exclusive range
None of the mentioned
Correct Answer: B — Exclusive range
Explanation:
1...10 means start from one and go till 9 and don't include 10.
The complement of while loop is until loop.
True
False
Correct Answer: A — True
Explanation:
The until loop is sort of like backward while.
It is necessary that always if should come with else block?
True
False
Correct Answer: B — False
Explanation:
Not necessary, if can execute alone.
Which of the following is valid conditional statement?
else
els
if else
None of the mentioned
Correct Answer: A — else
Explanation:
Else is valid conditional statement.
What is the use of else statement?
When the if condition is false then the next else condition will get executed
When the if condition is false then the elsif condition will get executed
When the if condition is false and if else condition is true then only it will get executed
None of the mentioned
Correct Answer: C — When the if condition is false and if else condition is true then only it will get executed
Explanation:
When the if expression gives false value and the else condition is true then only it will get executed.
What is the range of octal notation (\nnn)?
0-8
0-7
0-A
None of the mentioned
Correct Answer: B — 0-7
Explanation:
Octal notation ranges from 0-7.
Which of the following is not a valid datatype?
Float
Integer
Binary
Timedate
Correct Answer: D — Timedate
Explanation:
datetime is valid datatype but timedate is not a valid datatype.
What is the sequence of ruby strings?
16-bit bytes
8-bit bytes
10-bit bytes
None of the mentioned
Correct Answer: B — 8-bit bytes
Explanation:
They are simply the sequence of 8-bit bytes.
What does the notataion \b stands for?
Escape
Space
Backspace
Newline
Correct Answer: C — Backspace
Explanation:
This notataion is used for backspace.
Objects of which class does the integer from the range -2^30 to 2^(30-1) belong to?
Bignum
Octal
Fixnum
Binary
Correct Answer: C — Fixnum
Explanation:
Integer within this range are objects of the class fixnum.
Ruby can deal with both numbers and floating point values.
True
False
Correct Answer: A — True
Explanation:
We can assingn a integer and a floating point value to a variable.
What is the size of an integer data type in ruby?
-2^{30} to 2^{30}
-2^{30} to 2^{(30-1)}
-2^{29} to 2^{30}
-2^{60} to 2^{61}
Correct Answer: B — -2^{30} to 2^{(30-1)}
Explanation:
Integer ranges from -2^{30} to 2^{29} and lies in object of class Fixnum.
Ruby is a case-sensitive language.
True
False
Correct Answer: A — True
Explanation:
Ruby differentiates between small and capital letters and their meaning.
Why can not we use quotation marks (' or ") with boolean?
It indicates that we are talking about a string
It indicates that we are assining a value
It indicates that that we are replacing boolean data type with string data type
None of the mentioned
Correct Answer: A — It indicates that we are talking about a string
Explanation:
Quotation marks are used only with strings.
What will any variable evaluate to if it is of Boolean data type?
True
Nil
False
Either True or False
Correct Answer: D — Either True or False
Explanation:
Boolean data types will give the value either as True or False depending on the condition.
Which of the following datatypes are valid in Ruby?
Numbers
Boolean
String
All of the mentioned
Correct Answer: D — All of the mentioned
Explanation:
Ruby supports all the three (numbers,strings,boolean) data types.
Which of the following are used for comparison?
Equal to
Not equal to
Less than or greater than
All of the mentioned
Correct Answer: D — All of the mentioned
Explanation:
All of the mentioned above are used for comparisons.