Vidyalelo
Ruby Programming · all questions

Object Oriented Programming (OOP) Concepts in Ruby
practice.

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

40

Questions

1/2

Page

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

What is a class in Ruby?

Select an option to see the answer and solution.

Which keyword is used to define a class in Ruby?

Select an option to see the answer and solution.

What does the initialize method do in a Ruby class?

Select an option to see the answer and solution.

In Ruby, what is an object?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the purpose of the attr_accessor method in Ruby classes?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the purpose of inheritance in Ruby classes?

Select an option to see the answer and solution.

What is encapsulation in Ruby classes?

Select an option to see the answer and solution.

Which method is called automatically when an object is created in Ruby?

Select an option to see the answer and solution.

What does the super keyword do in a Ruby class?

Select an option to see the answer and solution.

Which of the following is a correct way to define a class method in Ruby?

Select an option to see the answer and solution.

What is the purpose of the include keyword in Ruby classes?

Select an option to see the answer and solution.

In Ruby, what does the extend keyword do?

Select an option to see the answer and solution.

What does the self keyword refer to in Ruby classes?

Select an option to see the answer and solution.

What is the purpose of the attr_reader method in Ruby classes?

Select an option to see the answer and solution.

Which keyword is used to access methods and variables within the same class in Ruby?

Select an option to see the answer and solution.

What is the purpose of the attr_writer method in Ruby classes?

Select an option to see the answer and solution.

In Ruby, what is a superclass?

Select an option to see the answer and solution.

Which keyword is used to define an instance method in Ruby?

Select an option to see the answer and solution.