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


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.


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


Question:
Among the following which operator has highest Precedence?

1.::

2. .

3. []

4. **


Question:
Among the following which operator has lowest Precedence?

1. .

2.^

3....

4.>>


Question:
Class variables in ruby begin with?

1.@

2.#

3.double @

4.##


Question:
Constants in ruby begin with ?

1.Lowercase

2. !

3.!

4.Uppercase


Question:
Default value of class variables is?

1.nil

2.infinite

3.-1

4.error


Question:
Default value of global variable is?

1.-1

2.nil

3.1

4.infinite


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


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


Question:
Global variables in ruby begin with?

1.@

2.#

3.$

4.&


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


Question:
Instance variables in ruby begin with?

1.@

2.#

3. $

4.&


Question:
Local variables in ruby begin with?

1. @ B. C.D.

2. _

3. *

4. #


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


Question:
Reserved word can not be used as?

1.constant

2.variable names

3.Both A and B

4.None of the above


Question:
Ruby is ?

1.procedural language

2. scripting language

3.Markup language

4. Stylesheet language


Question:
Ruby is designed by?

1.Yukihiro Matsumoto

2.Guido van Rossum

3.Tim Berners-Lee

4.Brendan Eich


Question:
Ruby was created in?

1.1992

2.1993

3.1994

4.1995


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


Question:
What does the 1..5 indicate?

1.Exclusive range

2. Both inclusive and exclusive range

3.Inclusive range

4.None of the above


Question:
What is the output of the given code?

my_string=Ruby
puts(my_string)

1.Ruby

2.Nil

3.Error

4.my_string


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


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.


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

num=4>>2
puts num

1. -2

2.0

3.2

4.1


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


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

1.4

2.8

3.16

4.32


Question:
What will the following expression evaluate to?

!true && !false

1.True

2.False

3.Syntax Error

4.None of These


Question:
What will the following expression evaluate to?

true || false

1.TRUE

2.FALSE

3.Syntax Error

4.None of the above


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

1.!

2.@

3.#

4. $


Question:
Which notation is used for Octal notation?

1.s

2.xnn

3.

4. n


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

1.Numbers

2.String

3.Boolean

4. All of the above


Question:
Which of the following is Exit Controlled loop?

1.do..while

2.For

3.Until

4.While


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

1.<<

2.^

3.~

4.None of the above


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


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

1.Arithmetic Operators

2.Comparison Operators

3.Similar operator

4.Parallel Assignment


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


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


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_


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.


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

1.define

2.define?

3.defined?

4.defined


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

1. *

2.**

3.^

4.%


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


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

1.break

2.next

3.redo

4.retry


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


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

1.Octa

2.Hexadecimal

3.Binary

4.Decimal


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


Question:
Why notation is used in Ruby?

1.Formfeed

2.Escape

3.Carriage return

4.Bell


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
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite 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!