Ruby on Rails/Ruby MCQ Questions Sample Test,Sample questions

Question:
 In range operator ... is used for ?

1.Creates a range from start point to end point inclusive.

2.Creates a range from start point to end point exclusive.

3.Creates a range from start point inclusive to end point exclusive.

4.Creates a range from start point exclusive to end point inclusive

Posted Date:-2022-08-22 07:47:14


Question:
 single-quoted strings don`t allow ?

1.substitution

2.backslash notation

3.single-quoted strings allow substitution and backslash notation.

4.single-quoted strings don`t allow substitution and allow backslash notation.

Posted Date:-2022-08-22 06:58:18


Question:
 When Whitespace characters such as spaces and tabs can not ignored in Ruby code?

1.While using strings

2.While using integer

3.while using float value

4. All of the above

Posted Date:-2022-08-22 06:01:23


Question:
Among the following which operator has highest Precedence?

1.::

2. .

3. []

4. **

Posted Date:-2022-08-22 08:32:16


Question:
Among the following which operator has lowest Precedence?

1. .

2.^

3....

4.>>

Posted Date:-2022-08-22 08:48:49


Question:
Class variables in ruby begin with?

1.@

2.#

3.double @

4.##

Posted Date:-2022-08-22 07:31:55


Question:
Constants in ruby begin with ?

1.Lowercase

2. !

3.!

4.Uppercase

Posted Date:-2022-08-22 07:34:23


Question:
Default value of class variables is?

1.nil

2.infinite

3.-1

4.error

Posted Date:-2022-08-22 07:33:27


Question:
Default value of global variable is?

1.-1

2.nil

3.1

4.infinite

Posted Date:-2022-08-22 06:07:23


Question:
eql? Operator is used for?

1.Used to test equality within a when clause of a case statement.

2. if the receiver and argument have both the same type and equal values.

3.if the receiver and argument have the same object id.

4. All of the above

Posted Date:-2022-08-22 07:44:43


Question:
equal? Operator is used for?

1.Used to test equality within a when clause of a case statement.

2. if the receiver and argument have both the same type and equal values.

3. if the receiver and argument have the same object id.

4. All of the above

Posted Date:-2022-08-22 08:41:34


Question:
Global variables in ruby begin with?

1.@

2.#

3.$

4.&

Posted Date:-2022-08-22 06:06:42


Question:
Guess the operator : If Condition is true ? Then value X : Otherwise value Y?

1.Range Operators

2.Ternary Operator

3.Parallel Operator

4.Arithmetic operator

Posted Date:-2022-08-22 08:42:44


Question:
Instance variables in ruby begin with?

1.@

2.#

3. $

4.&

Posted Date:-2022-08-22 07:29:02


Question:
Local variables in ruby begin with?

1. @ B. C.D.

2. _

3. *

4. #

Posted Date:-2022-08-22 06:08:11


Question:
Objects of which class does the integer from the range -2^60 to 2^(60-1) belong to?

1.Octal

2.Bignum

3.Fixnum

4.Binary

Posted Date:-2022-08-22 06:59:17


Question:
Reserved word can not be used as?

1.constant

2.variable names

3.Both A and B

4.None of the above

Posted Date:-2022-08-22 06:02:38


Question:
Ruby is ?

1.procedural language

2. scripting language

3.Markup language

4. Stylesheet language

Posted Date:-2022-08-22 05:56:07


Question:
Ruby is designed by?

1.Yukihiro Matsumoto

2.Guido van Rossum

3.Tim Berners-Lee

4.Brendan Eich

Posted Date:-2022-08-22 05:57:01


Question:
Ruby was created in?

1.1992

2.1993

3.1994

4.1995

Posted Date:-2022-08-22 05:57:54


Question:
What does end represent?

1.keyword represents the ending of loop

2.keyword represents the start of loop

3. keyword represents the start and ending of loop

4.keyword represents the infinite loop

Posted Date:-2022-08-22 09:14:59


Question:
What does the 1..5 indicate?

1.Exclusive range

2. Both inclusive and exclusive range

3.Inclusive range

4.None of the above

Posted Date:-2022-08-22 09:41:57


Question:
What is the output of the given code?

my_string=Ruby
puts(my_string)

1.Ruby

2.Nil

3.Error

4.my_string

Posted Date:-2022-08-22 07:38:30


Question:
What is the sequence of ruby strings?

1.16-bit bytes

2.8-bit bytes

3.4-bit bytes

4.None of the above

Posted Date:-2022-08-22 06:56:17


Question:
What is the use of break statement?

1.Terminates the most External loop.

2.Terminates all loop

3.Terminates the program

4. Terminates the most internal loop.

Posted Date:-2022-08-22 09:39:40


Question:
What is true about Until loop?

1.Executes code while conditional is true

2.In until loop increment is not required

3. Executes code while conditional is false

4.None of These

Posted Date:-2022-08-22 09:38:35


Question:
What is true about while loop?

1.Executes code while conditional is true

2. In while loop increment is not required

3. Executes code while conditional is false

4.None of the above

Posted Date:-2022-08-22 09:12:29


Question:
What will be the output of the given code?

 boolean_var = !(100 / 10 === 10)
puts boolean_var

1.TRUE

2.FALSE

3.Type Error

4.Syntax Error

Posted Date:-2022-08-22 08:38:58


Question:
What will be the output of the given code?

a=1
b=1
while a&&b
puts a+b
end

1.2

2.2 2 2 2 2

3.Infinite Loop

4.Syntax Error

Posted Date:-2022-08-22 09:37:27


Question:
What will be the output of the given code?

boolean_var = !true || (true || 36 != 6**2)
puts boolean_var

1.TRUE

2.FALSE

3.Error

4.None of the above

Posted Date:-2022-08-22 09:02:43


Question:
What will be the output of the given code?

boolean_var = 15 < 16 && 15 < 15
puts boolean_var

1.TRUE

2.FALSE

3.Type Error

4.Syntax Error

Posted Date:-2022-08-22 08:33:40


Question:
What will be the output of the given code?

boolean_var = 3**2 != 2**3 || true
puts boolean_var

1.TRUE

2.FALSE

3.1

4.0

Posted Date:-2022-08-22 08:37:44


Question:
What will be the output of the given code?

boolean_var = false || -20 > -18
puts boolean_var

1.TRUE

2.FALSE

3.Type Error

4.Syntax Error

Posted Date:-2022-08-22 09:01:38


Question:
What will be the output of the given code?

counter = 1
while counter < 5
  puts counter
  counter = counter + 1
end

1. Prints the number from 1 to 4

2.Prints the number from 1 to 5

3. Prints the number from 2 to 5

4.Prints the number from 2 to 4

Posted Date:-2022-08-22 09:46:38


Question:
What will be the output of the given code?

counter = true
while counter !=false
  puts counter
end

1.TRUE

2.FALSE

3.Syntax Error

4.Infinite Loop

Posted Date:-2022-08-22 09:23:09


Question:
What will be the output of the given code?

for i in 1...3  
  for j in 1..3
  puts j
  end
end

1.1 2 1 2

2. 0 1 2 0 1 2

3.1 2 3 1 2 3

4. 1 2 3 1 2

Posted Date:-2022-08-22 09:44:16


Question:
What will be the output of the given code?

for i in 1..5 && j in 5..10
puts i+j
end

1. 6 8 10 12 14 16

2.Syntax Error

3.6 8 10 12 14

4.Type Error

Posted Date:-2022-08-22 09:22:07


Question:
What will be the output of the given code?

for num in 1...4

   puts num*num

end

1. 0 1 4 9.

2.1 4 9 16

3. 0 1 2 3

4.1 2 3

Posted Date:-2022-08-22 09:20:41


Question:
What will be the output of the given code?

for num in 1...5
  puts num
end

1.1 2 3 4

2. 1 2 3 4 5

3.0 1 2 3 4

4.0 1 2 3 4 5

Posted Date:-2022-08-22 09:16:44


Question:
What will be the output of the given code?

i = 4
while i > 0 do
  print i
  i -= 1
end

1.321

2.3210

3.4321

4.43210

Posted Date:-2022-08-22 09:48:32


Question:
What will be the output of the given code?

i=1
for i in 6..10
puts i**2
end

1. 36 49 64 81

2.49 64 81 100

3. 49 64 81

4.36 49 64 81 100

Posted Date:-2022-08-22 09:45:17


Question:
What will be the output of the given code?

num=(10<11)||(11===11)? (11===11.0): 0
puts num

1. TRUE

2.FALSE

3.1

4.0

Posted Date:-2022-08-22 09:00:45


Question:
What will be the output of the given code?

num=4>>2
puts num

1. -2

2.0

3.2

4.1

Posted Date:-2022-08-22 08:35:34


Question:
What will be the output of the given code?

while a&&b
puts a
end

1.TRUE

2.FALSE

3.Syntax Error

4.Name Error

Posted Date:-2022-08-22 09:47:47


Question:
What will be the output of the given code?
num=4<<2
puts num

1.4

2.8

3.16

4.32

Posted Date:-2022-08-22 08:50:27


Question:
What will the following expression evaluate to?

!true && !false

1.True

2.False

3.Syntax Error

4.None of These

Posted Date:-2022-08-22 09:04:54


Question:
What will the following expression evaluate to?

true || false

1.TRUE

2.FALSE

3.Syntax Error

4.None of the above

Posted Date:-2022-08-22 08:39:52


Question:
Which character is used to give comment in ruby?

1.!

2.@

3.#

4. $

Posted Date:-2022-08-22 06:04:18


Question:
Which notation is used for Octal notation?

1.s

2.xnn

3.

4. n

Posted Date:-2022-08-22 06:53:17


Question:
Which of the following datatypes are valid in Ruby?

1.Numbers

2.String

3.Boolean

4. All of the above

Posted Date:-2022-08-22 06:54:11


Question:
Which of the following is Exit Controlled loop?

1.do..while

2.For

3.Until

4.While

Posted Date:-2022-08-22 09:43:15


Question:
Which of the following is not a type of Bitwise Operators?

1.<<

2.^

3.~

4.None of the above

Posted Date:-2022-08-22 07:45:54


Question:
Which of the following is not a type of loop in ruby?

1.For Loop

2.Foreach Loop

3.Until Loop

4.While Loop

Posted Date:-2022-08-22 09:11:16


Question:
Which of the following is not type of operator in ruby?

1.Arithmetic Operators

2.Comparison Operators

3.Similar operator

4.Parallel Assignment

Posted Date:-2022-08-22 07:43:40


Question:
Which of the following Ruby Pseudo Variables is used to return current line number in the source file?

1._FILE_

2._CURRENT_

3. _LINE_

4.None of the above

Posted Date:-2022-08-22 06:09:56


Question:
Which of the following Ruby Pseudo Variables is used to return the name of the current source file?

1._FILE_

2. _CURRENT_

3._LINE_

4.None of the above

Posted Date:-2022-08-22 07:35:51


Question:
Which of the following Ruby Pseudo-Variables is used for The receiver object of the current method?

1.self B. C. D.

2.current

3.nil

4. _FILE_

Posted Date:-2022-08-22 06:08:53


Question:
Which of the following statement is not a feature of ruby?

1.Ruby is interpreted programming language.

2.Ruby can be used to write Common Gateway Interface (CGI) scripts.

3.Ruby can be embedded into Hypertext Markup Language (HTML).

4.Ruby can not be connected to Database.

Posted Date:-2022-08-22 06:00:24


Question:
Which operator is used to check variable and method are defined or not?

1.define

2.define?

3.defined?

4.defined

Posted Date:-2022-08-22 08:45:34


Question:
Which operator is used to find exponent in ruby?

1. *

2.**

3.^

4.%

Posted Date:-2022-08-22 08:40:40


Question:
Which statement is used to Jumps to the next iteration of the most internal loop?

1.break

2. next C. D.

3.redo

4.retry

Posted Date:-2022-08-22 09:13:13


Question:
Which statement is used to restarts the invocation of the iterator call?

1.break

2.next

3.redo

4.retry

Posted Date:-2022-08-22 09:14:10


Question:
Which statement is used to Restarts this iteration of the most internal loop, without checking loop condition?

1.break

2.next

3.redo

4.retry

Posted Date:-2022-08-22 09:40:44


Question:
Which type of number(0b1011 ) is ?

1.Octa

2.Hexadecimal

3.Binary

4.Decimal

Posted Date:-2022-08-22 07:39:37


Question:
Why can not we use quotation marks ("or") with boolean?

1. It indicates that we are talking about a string

2.It indicates that we are assining a value

3.It indicates that that we are replacing boolean data type with string data type

4.None of the above

Posted Date:-2022-08-22 07:37:40


Question:
Why notation is used in Ruby?

1.Formfeed

2.Escape

3.Carriage return

4.Bell

Posted Date:-2022-08-22 07:36:42


More MCQS

  1. Ruby MCQ Questions
  2. Ruby on Rails Multiple choice Questions Set 1
  3. Ruby on Rails Multiple choice Questions Set 2
  4. Ruby on Rails Multiple choice Questions Set 3
  5. Ruby on Rails MCQ
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!