Vidyalelo
Ruby Programming · all questions

Classes and Objects in Ruby
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

36

Questions

1/2

Page

Pick an option on a question to see the right answer and solution.

What is the keyword used to define a class in Ruby?

Select an option to see the answer and solution.

Which keyword is used to create a new instance of a class in Ruby?

Select an option to see the answer and solution.

How do you define a constructor in Ruby?

Select an option to see the answer and solution.

Which of the following is used to access instance variables in Ruby?

Select an option to see the answer and solution.

What does the attr_accessor method do in Ruby?

Select an option to see the answer and solution.

What is the purpose of the initialize method in Ruby?

Select an option to see the answer and solution.

What is the method used to inherit from a superclass in Ruby?

Select an option to see the answer and solution.

What does the super keyword do in Ruby?

Select an option to see the answer and solution.

What is the method used to check if an object is an instance of a particular class in Ruby?

Select an option to see the answer and solution.

What is the method used to define class methods in Ruby?

Select an option to see the answer and solution.

What is the method used to define instance methods in Ruby?

Select an option to see the answer and solution.

What is the keyword used to refer to the current instance of a class in Ruby?

Select an option to see the answer and solution.

Which method is used to define class variables in Ruby?

Select an option to see the answer and solution.

What does the private keyword do in a Ruby class?

Select an option to see the answer and solution.

What does the protected keyword do in a Ruby class?

Select an option to see the answer and solution.

How do you access instance variables in Ruby?

Select an option to see the answer and solution.

What is the method used to define instance variables in Ruby?

Select an option to see the answer and solution.

Which keyword is used to inherit a class in Ruby?

Select an option to see the answer and solution.

What does the super keyword do in Ruby classes?

Select an option to see the answer and solution.

What is the syntax for defining a class method in Ruby?

Select an option to see the answer and solution.