Q.
What is the result of the expression: 5 / 2 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 2
Q.
Why is the library function 'puts'used for?
Prints whatever is given and insert a new(blank) line
Gets input from the user
Prints whatever is given and print it to the screen
None of the mentioned
Show Explanation
Explanation:
The correct answer to the question is: Prints whatever is given and insert a new(blank) line
Q.
Why do we use comments?
For later use to understand the working of the program
All of the mentioned
It is an efficient way of programming
It makes easy for the third person to understand
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
Which method is used to convert a string to uppercase in Ruby?
.upcase
.uppercase
.to_uppercase
.to_upper
Show Explanation
Explanation:
The correct answer to the question is: .upcase
Q.
What does the 'print' method do in Ruby?
Converts to string
Prints to console
Finds the length
Reads input from user
Show Explanation
Explanation:
The correct answer to the question is: Prints to console
Q.
What is the output of the code?
Amil Jones
None of the mentioned
What's your first name? amil
What's your last name? jones
My name is Amil Jones
My name is Amil jones
Show Explanation
Explanation:
The correct answer to the question is: What's your first name? amil
What's your last name? jones
My name is Amil Jones
Q.
What is the output of the given code?
None of the mentioned
15 19 23
10 20
-5 -5 -5
Show Explanation
Explanation:
The correct answer to the question is: -5 -5 -5
Q.
What is the output of given code?
None of the mentioned
Undefined method
I'am Learning RUBY Language
"I'AM LEARNING RUBY LANGUAGE"
Show Explanation
Explanation:
The correct answer to the question is: "I'AM LEARNING RUBY LANGUAGE"
Q.
Which of the following is NOT a valid data type in Ruby?
Float
Integer
Double
String
Show Explanation
Explanation:
The correct answer to the question is: Double
Q.
In Ruby, what does the 'if' statement evaluate?
Expression
String
Integer
Boolean value
Show Explanation
Explanation:
The correct answer to the question is: Boolean value
Q.
What will be the output of the given code?
True False
False False
None of the mentioned
True True
Show Explanation
Explanation:
The correct answer to the question is: True False
Q.
Which of the following is a valid variable name in Ruby?
_variable
my_variable
variable-1
123variable
Show Explanation
Explanation:
The correct answer to the question is: my_variable
Q.
What is the output of the expression: 7 / 2 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 3
Q.
What is the correct way to cast a string to an integer in Ruby?
int(string)
string.integer
string.to_i
string.convert(:integer)
Show Explanation
Explanation:
The correct answer to the question is: string.to_i
Q.
What will the following expression evaluate to?
(true && false) | | (!true)
True
False
Error
None of the mentioned
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
Which of the following is the valid string method?
The .downcase method
The .irreverse method
The .length method
The .upcase method
Show Explanation
Explanation:
The correct answer to the question is: The .irreverse method
Q.
The downcase method changes the whole string to smallcase letters.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Which method is used to convert a string to lowercase in Ruby?
.downcase
.to_lowercase
.lowercase
.lower
Show Explanation
Explanation:
The correct answer to the question is: .downcase
Q.
What is the correct syntax for string interpolation in Ruby?
variable.to_string
$(variable)
"#{variable}"
%(variable)
Show Explanation
Explanation:
The correct answer to the question is: "#{variable}"
Q.
What is the output of the expression: "5".to_i + 2 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 7
Q.
What is the correct way to define a block in Ruby?
do code end
block code
function code
block { code }
Show Explanation
Explanation:
The correct answer to the question is: block { code }
Q.
What is the result of the expression: 9 / 2 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 2.5
Q.
What will the following expression evaluate to?
true | | false
None of the mentioned
Error
False
True
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Which sequence can be used to substitute the value of any ruby expression in a string?
#(expr)
None of the mentioned
#expr
#{expr}
Show Explanation
Explanation:
The correct answer to the question is: #{expr}
Q.
The following is the correct way to use multiline comment.
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
What is the output of the following?
Error in compilation
Undefined local variable ruby
4
ybur
Show Explanation
Explanation:
The correct answer to the question is: Undefined local variable ruby
Q.
What is the purpose of the require keyword in Ruby?
Defines a new module
Loads a specific Ruby file
Creates a new class
Imports external libraries
Show Explanation
Explanation:
The correct answer to the question is: Imports external libraries
Q.
What is the correct way to define a symbol in Ruby?
symbol = Symbol("value")
symbol = :value
symbol = 'value'
symbol = "value"
Show Explanation
Explanation:
The correct answer to the question is: symbol = :value
Q.
What is the correct syntax for accessing a class method?
Class.new.method_name
Class.method_name
method_name(Class)
object.method_name
Show Explanation
Explanation:
The correct answer to the question is: Class.method_name
Q.
Why is gets not preferred instead of gets.chomp?
All of the mentioned
Chomp erases the value stored in the variable
Gets remove an extra new line
Gets add an extra new line while chomp removes it
Show Explanation
Explanation:
The correct answer to the question is: Gets add an extra new line while chomp removes it
Q.
The '=' is used for assigning value to variable?
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Which of the following is the correct way to define a variable in Ruby?
variable name = value
name = value
var var_name = value
var_name = value
Show Explanation
Explanation:
The correct answer to the question is: var_name = value
Q.
What is the result of the expression: 3 ** 3 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 27
Q.
What is the default file extension for Ruby files?
Show Explanation
Explanation:
The correct answer to the question is: .rb
Q.
What do we mean by expression substitution?
None of the mentioned
Substituting string functions
Storing string value
Embedding the value of Ruby expression into a string using #{ }
Show Explanation
Explanation:
The correct answer to the question is: Embedding the value of Ruby expression into a string using #{ }
Q.
What is the extension used for saving the ruby file?
.rb extension
.ruby extension
None of the mentioned
.rrb extension
Show Explanation
Explanation:
The correct answer to the question is: .rb extension
Q.
What is the correct syntax to declare and initialize a variable in Ruby?
variable_name = value
var_name = value
var var_name = value
variable var_name = value
Show Explanation
Explanation:
The correct answer to the question is: variable_name = value
Q.
Which of the following features does the 2.0 version of ruby supports?
Security fixes
Method keyword arguments
All of the mentioned
New literals
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
How do you check the truthiness of a value in Ruby?
if (value) then code end
if value.is_truthy?
if value != false
if value do code end
Show Explanation
Explanation:
The correct answer to the question is: if value != false
Q.
How do you get the current date and time in Ruby?
time = Time.now
datetime = DateTime.now
date = Date.now
now = Date.today
Show Explanation
Explanation:
The correct answer to the question is: time = Time.now
Q.
What is the correct syntax for a multiline comment in Ruby?
# ... #
/* ... */
// ... //
''' ... '''
Show Explanation
Explanation:
The correct answer to the question is: ''' ... '''
Q.
What does the && operator do in Ruby?
Logical AND
Bitwise AND
Logical OR
Logical NOT
Show Explanation
Explanation:
The correct answer to the question is: Logical AND
Q.
What is the correct way to concatenate two strings in Ruby?
str1.combine(str2)
str1.append(str2)
str1.concat(str2)
str1 + str2
Show Explanation
Explanation:
The correct answer to the question is: str1 + str2
Q.
In Ruby, what is the keyword used to define a constant?
CONSTANT_NAME = value
constant name : value
constant_name = value
constantName(value)
Show Explanation
Explanation:
The correct answer to the question is: CONSTANT_NAME = value
Q.
Which operator is used for exponentiation in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: **
Q.
What symbol is used to denote the end of a statement in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: ;
Q.
What is the size of an integer data type in ruby?
-2 to 2
-2 to 2
-2 to 2
-2 to 2
Show Explanation
Explanation:
The correct answer to the question is: -2 to 2
Q.
What does the 'chomp' method do in Ruby?
Removes trailing whitespace
Reads input from user
Splits a string
Converts to integer
Show Explanation
Explanation:
The correct answer to the question is: Removes trailing whitespace
Q.
What does the 'gets' method do in Ruby?
Converts to string
Finds the length
Reads input from user
Prints to console
Show Explanation
Explanation:
The correct answer to the question is: Reads input from user
Q.
How do you call a method in Ruby?
object.method_name()
method_name(object)
method_name()
object.method_name
Show Explanation
Explanation:
The correct answer to the question is: object.method_name
Q.
Which of these operators is used for string concatenation?
Show Explanation
Explanation:
The correct answer to the question is: +
Q.
In Ruby, what is the default file extension for Ruby files?
Show Explanation
Explanation:
The correct answer to the question is: .rb
Q.
What does the **= assignment operator do?
Multiplies the value twice
It is the multiplication operator.
None of the mentioned
It is used as exponent like 2**3=8
Show Explanation
Explanation:
The correct answer to the question is: It is used as exponent like 2**3=8
Q.
How do you break out of a loop in Ruby?
exit()
end()
continue()
break()
Show Explanation
Explanation:
The correct answer to the question is: break()
Q.
first_name,Last_name=gets.chomp,gets.chomp is the correct way to get the input from the user.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the correct way to declare a variable in Ruby without assigning a value?
var_name
None of the above
var_name = ""
var_name = nil
Show Explanation
Explanation:
The correct answer to the question is: var_name
Q.
What is the correct syntax for creating a hash in Ruby?
Hash.new("key", "value")
hash.add("key", "value")
{"key1": "value1", "key2": "value2"}
hash = {}
Show Explanation
Explanation:
The correct answer to the question is: {"key1": "value1", "key2": "value2"}
Q.
Which of the following is a valid assignment operator?
*=
+=
-=
All of the mentioned
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
Which of the following is the correct way to define a constant in Ruby?
constant_name : value
CONSTANT_NAME = value
constant_name = value
constantName(value)
Show Explanation
Explanation:
The correct answer to the question is: CONSTANT_NAME = value
Q.
Which of the following languages syntax matches with the Ruby's syntax?
Show Explanation
Explanation:
The correct answer to the question is: Perl
Q.
What is the correct way to declare and initialize an array in Ruby?
array = array_name[]
array_name = array[]
array array_name = []
array_name = []
Show Explanation
Explanation:
The correct answer to the question is: array_name = []
Q.
How do you access a value from a hash in Ruby?
hash.at("key")
hash["key"]
hash.get("key")
hash.find("key")
Show Explanation
Explanation:
The correct answer to the question is: hash["key"]
Q.
How do you add two numbers in Ruby?
b.add(a)
a.add(b)
add(a, b)
a + b
Show Explanation
Explanation:
The correct answer to the question is: a + b
Q.
Which symbol is used for the modulo operation in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: %
Q.
How do you pass arguments to a method in Ruby?
method_name arg1 arg2
method_name { arg1, arg2 }
method_name.with(arg1, arg2)
method_name(arg1, arg2)
Show Explanation
Explanation:
The correct answer to the question is: method_name(arg1, arg2)
Q.
What is the correct way to declare and initialize a variable in Ruby?
var_name = value
variable var_name = value
variable_name = value
var var_name = value
Show Explanation
Explanation:
The correct answer to the question is: variable_name = value
Q.
Which of the following is the correct way to declare a constant in Ruby?
constantName(value)
CONSTANT_NAME = value
constant_name = value
constant_name : value
Show Explanation
Explanation:
The correct answer to the question is: CONSTANT_NAME = value
Q.
What will we the output of the given code?
unterminated string meets end of file
iam learning ruby language
"i'am learning ruby language"
i'AM lEARNING ruby lANGUAGE
Show Explanation
Explanation:
The correct answer to the question is: unterminated string meets end of file
Q.
How do you compare two objects in Ruby?
object1 === object2
compare(object1, object2)
object1 == object2
object1.equals(object2)
Show Explanation
Explanation:
The correct answer to the question is: object1 == object2
Q.
What is the correct way to define a conditional statement in Ruby?
if condition then code end
when condition; code
if condition: code
if (condition) { code }
Show Explanation
Explanation:
The correct answer to the question is: if (condition) { code }
Q.
Which of the following is the correct way to define a range in Ruby?
[1 to 10]
{1..10}
(1..10)
<1,10>
Show Explanation
Explanation:
The correct answer to the question is: (1..10)
Q.
What will be the output of the following?
Show Explanation
Explanation:
The correct answer to the question is: YBUR
Q.
What is the result of the expression: 6 / 2 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 2
Q.
What is the correct way to define an array in Ruby?
array = new Array
array = Array.new
array = ["element1", "element2"]
array = list("element1", "element2")
Show Explanation
Explanation:
The correct answer to the question is: array = ["element1", "element2"]
Q.
We use semicolon or parentheses after every print or puts statement.
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
What does the .upcase method do?
Convert only lowercase string to uppercase and vice-versa
Convert the string to uppercase
None o the mentioned
Convert the string to lowercase
Show Explanation
Explanation:
The correct answer to the question is: Convert the string to uppercase
Q.
What is the method used to convert a string to lowercase in Ruby?
.lower
.to_lower
.downcase
.to_lowercase
Show Explanation
Explanation:
The correct answer to the question is: .downcase
Q.
What is the output of the expression: "5" + "2" in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 52
Q.
Which of the following is the correct way to declare a variable in Ruby with a default value?
var_name = value
var_name => value
var_name << value
var_name := value
Show Explanation
Explanation:
The correct answer to the question is: var_name = value
Q.
Which of the following are used for comparison?
All of the mentioned
Not equal to
Less than or greater than
Equal to
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
Which of the following is supported by Ruby?
Automatic Memory Management
All of the Mentioned
Multiple Programming Paradigms
Dynamic Type System
Show Explanation
Explanation:
The correct answer to the question is: All of the Mentioned
Q.
Which method is used to convert a string to an array of characters in Ruby?
.to_array
.split
.chars
.to_chars
Show Explanation
Explanation:
The correct answer to the question is: .chars
Q.
Which operator is used for subtraction in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: -
Q.
In Ruby, what is the keyword used to define a loop that repeats until a condition is true?
Show Explanation
Explanation:
The correct answer to the question is: until
Q.
What is the result of the expression: 10 % 3 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: 1
Q.
What is the difference between nil and false?
nil is a string, false is a boolean
nil represents absence of value, false represents a boolean value
Both are the same
nil is a number, false is a boolean
Show Explanation
Explanation:
The correct answer to the question is: nil represents absence of value, false represents a boolean value
Q.
Which symbol is used to concatenate strings in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: <<
Q.
What is the default return value of a method in Ruby?
The value of the last expression
FALSE
TRUE
nil
Show Explanation
Explanation:
The correct answer to the question is: nil
Q.
Ruby does not support ++ operator, it only supports += operator.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Space between 2+5 or 2 + 5 is valid but =begin and = begin is not valid.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Methods should not be written inside double quotes.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the sequence of ruby strings?
10-bit bytes
None of the mentioned
16-bit bytes
8-bit bytes
Show Explanation
Explanation:
The correct answer to the question is: 8-bit bytes
Q.
What does the 'puts' method do in Ruby?
Finds the length
Reads input from user
Converts to string
Prints to console
Show Explanation
Explanation:
The correct answer to the question is: Prints to console
Q.
What is the difference between =~ and == operators?
=~ checks for equality, == checks for string pattern matching
None of the above
Both operators are the same
=~ checks for string pattern matching, == checks for equality
Show Explanation
Explanation:
The correct answer to the question is: =~ checks for string pattern matching, == checks for equality
Q.
In Ruby, what is the keyword used to define a method?
define
method
function
def
Show Explanation
Explanation:
The correct answer to the question is: def
Q.
How to comment a single line?
None of the mentioned
Using //
Using #
Using begin and end
Show Explanation
Explanation:
The correct answer to the question is: Using #
Q.
It is must for Ruby to use a compiler.
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
Which method is used to find the length of an array in Ruby?
.count
.size
.length_of
.length
Show Explanation
Explanation:
The correct answer to the question is: .length
Q.
What symbol is used to denote comments in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: #
Q.
The .length method is used to check number of characters.
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
What will the following code evaluate to?
False
None of the mentioned
Syntax error
True
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What does the notataion \b stands for?
Space
Backspace
Escape
Newline
Show Explanation
Explanation:
The correct answer to the question is: Backspace
Q.
Which method is used to check if a string contains a specific substring in Ruby?
.contains
.hasSubstring
.exist
.include?
Show Explanation
Explanation:
The correct answer to the question is: .include?
Q.
How do you define a range in Ruby?
range = start.to(end)
range = "start..end"
range = start..end
range = Range.new("start", "end")
Show Explanation
Explanation:
The correct answer to the question is: range = start..end
Q.
What is the data type of the value "true" in Ruby?
Float
String
Boolean
Integer
Show Explanation
Explanation:
The correct answer to the question is: Boolean
Q.
Which method is used to check if a variable is nil in Ruby?
.empty?
.is_nil?
.null?
.nil?
Show Explanation
Explanation:
The correct answer to the question is: .nil?
Q.
What is the method used to check the data type of a variable in Ruby?
.typeof
.class
.type
.datatype
Show Explanation
Explanation:
The correct answer to the question is: .class
Q.
What are the different types of comments in Ruby?
Single-line # and multi-line """ """
Single-line // and multi-line """ """
Single-line // and multi-line /* */
Single-line # and multi-line ``
Show Explanation
Explanation:
The correct answer to the question is: Single-line # and multi-line """ """
Q.
Which of the following datatypes are valid in Ruby?
All of the mentioned
String
Numbers
Boolean
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
What is the method used to check if a variable is empty in Ruby?
.is_empty?
.null?
.empty?
.has_content?
Show Explanation
Explanation:
The correct answer to the question is: .empty?
Q.
Ruby can deal with both numbers and floating point values.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What does %x!ls! represents?
Same as back tick command output 'ls'
None of the mentioned
Same as 'x'
Same as "xls"
Show Explanation
Explanation:
The correct answer to the question is: Same as back tick command output 'ls'
Q.
What is the purpose of the gem command in Ruby?
Installs and manages Ruby libraries
Defines Ruby classes
Runs Ruby code
Compiles Ruby code
Show Explanation
Explanation:
The correct answer to the question is: Installs and manages Ruby libraries
Q.
What is the correct syntax for defining a variable in Ruby?
name: value
name = value
variable name = value
var name = "value"
Show Explanation
Explanation:
The correct answer to the question is: name = value
Q.
Boolean opeartors are also known as logical operators.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
The == 'is equal to' is known as relational operator.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Which of the following is a valid boolean operator?
not(!)
or(| |)
All of the mentioned
and(&&)
Show Explanation
Explanation:
The correct answer to the question is: All of the mentioned
Q.
Ruby is a case-sensitive language.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Ruby can be used for developing internet and intranet applications.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
In Ruby, what is the correct way to define a constant?
CONSTANT_NAME = value
constant_name = value
constant name : value
constant_name(value)
Show Explanation
Explanation:
The correct answer to the question is: CONSTANT_NAME = value
Q.
Which of the following is not a valid library function?
Show Explanation
Explanation:
The correct answer to the question is: Get
Q.
What will any variable evaluate to if it is of Boolean data type?
Nil
False
True
Either True or False
Show Explanation
Explanation:
The correct answer to the question is: Either True or False
Q.
Which of the following is the correct way to start a single-line comment in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: #
Q.
How to comment multiple lines in ruby?
No option to comment
All of the mentioned
Using multiline comments
Using single line comments
Show Explanation
Explanation:
The correct answer to the question is: Using multiline comments
Q.
What is the result of the expression: true && false in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: FALSE
Q.
What is the output of the expression: "hello" + "world" in Ruby?
helloworld
"hello" "world"
hello+world
hello world
Show Explanation
Explanation:
The correct answer to the question is: helloworld
Q.
What is the method used to check if a string contains a specific substring in Ruby?
.hasSubstring
.contains
.include?
.exist
Show Explanation
Explanation:
The correct answer to the question is: .include?
Q.
For getting an input from the user which method is used?
chomp
get-s
get
gets.chomp
Show Explanation
Explanation:
The correct answer to the question is: gets.chomp
Q.
What is the use of .capitalize method?
It capitalizes the entire string
It capitalize the strings which are in small case
All of the mentioned
It capitalize on the first letter of the string
Show Explanation
Explanation:
The correct answer to the question is: It capitalize on the first letter of the string
Q.
What is the correct way to declare a variable in Ruby?
const name = "value"
var name = "value"
let name = "value"
name = "value"
Show Explanation
Explanation:
The correct answer to the question is: name = "value"
Q.
The .upcase and .capitalize method are used for capitalizing the whole string.
Show Explanation
Explanation:
The correct answer to the question is: False
Q.
What does %Q{ Learn ruby language } represents?
" learn ruby language "
" Learn Ruby language "
"%{ Learn Ruby language }"
None of the mentioned
Show Explanation
Explanation:
The correct answer to the question is: " Learn Ruby language "
Q.
What is the correct syntax for printing a message to the console?
puts("message")
console.log("message")
write("message")
print("message")
Show Explanation
Explanation:
The correct answer to the question is: puts("message")
Q.
The following syntax is used for multiline comment.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Which of the following is not a valid datatype?
Integer
Float
Timedate
Binary
Show Explanation
Explanation:
The correct answer to the question is: Timedate
Q.
This the right way to comment a single line.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the output of the expression: "10" * 3 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: "101010"
Q.
The given two expression means the same.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the correct way to define a method in Ruby?
method method_name(parameters) = code
def method_name(parameters) code end
method_name(parameters) -> code
function method_name(parameters) code
Show Explanation
Explanation:
The correct answer to the question is: def method_name(parameters) code end
Q.
What is the method used to check if a variable is defined in Ruby?
.has_value?
.exist?
.is_defined?
.defined?
Show Explanation
Explanation:
The correct answer to the question is: .defined?
Q.
Ruby can be embedded into Hypertext Markup Language(HTML).
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What does the 'return' keyword do in Ruby methods?
Exits the method with a value
Converts to integer
Prints to console
Continues the loop
Show Explanation
Explanation:
The correct answer to the question is: Exits the method with a value
Q.
What is the method used to check if a variable is of a specific class in Ruby?
.class_of
.typeof
.is_a?
.type_of
Show Explanation
Explanation:
The correct answer to the question is: .is_a?
Q.
What does %{Learn ruby language} represents?
"%{Learn Ruby language}"
" Learn Ruby language "
None of the mentioned
"Learn Ruby language"
Show Explanation
Explanation:
The correct answer to the question is: "Learn Ruby language"
Q.
What is the result of the expression: 4 > 2 && 5 < 7 in Ruby?
Show Explanation
Explanation:
The correct answer to the question is: TRUE
Q.
The boolean operator && only result in true when both the values are true?
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the method used to check if a variable is numeric in Ruby?
.number?
.numeric_value?
.is_numeric?
.numeric?
Show Explanation
Explanation:
The correct answer to the question is: .is_numeric?
Q.
Assignment operator is also known as relational operator.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
Why can not we use quotation marks (' or ") with boolean?
It indicates that we are talking about a string
It indicates that that we are replacing boolean data type with string data type
It indicates that we are assining a value
None of the mentioned
Show Explanation
Explanation:
The correct answer to the question is: It indicates that we are talking about a string
Q.
Which of the following is a valid way to declare a variable in Ruby?
myVar
myVar = "10"
myVar = 10
10 = myVar
Show Explanation
Explanation:
The correct answer to the question is: myVar = 10
Q.
In Ruby, what is the keyword used to define a class?
cls
class
define
defclass
Show Explanation
Explanation:
The correct answer to the question is: class
Q.
Ruby is an object oriented general purpose programming language.
Show Explanation
Explanation:
The correct answer to the question is: True
Q.
What is the data type of the value "Hello, World" in Ruby?
String
Boolean
Integer
Float
Show Explanation
Explanation:
The correct answer to the question is: String
Q.
What is the output of the the given code?
Error in compilation
Undefined Error
My name is #{Name}
Name variable not defined earlier
Show Explanation
Explanation:
The correct answer to the question is: Name variable not defined earlier