What does the following code do?
hash = { a: 1, b: 2, c: 3 }
hash.each_key { |key| puts key }
hash = { a: 1, b: 2, c: 3 }
hash.each_key { |key| puts key }
Anonymous Quiz
3%
Prints only the values of the hash
92%
Prints only the keys of the hash
3%
Prints both keys and values of the hash
2%
Runtime error
Which of the following methods adds an element to the end of an array?
Anonymous Quiz
8%
add
71%
push
4%
insert
17%
append
👎1
Which of the following methods converts a string to a number?
Anonymous Quiz
5%
to_integer
4%
to_num
90%
to_i
1%
parse
What does the super keyword do in Ruby?
Anonymous Quiz
0%
Defines a new method for the class
4%
Passes control to another block
7%
Creates a superclass
89%
Calls the parent class's method with the same arguments
Which design pattern is typically used to construct objects with complex creation logic?
Anonymous Quiz
2%
Observer
8%
Singleton
47%
Builder
42%
Factory
What is the name of the architectural style that separates responsibilities into models, views, and controllers?
Anonymous Quiz
1%
REST
11%
MVP (Model-View-Presenter)
1%
MVVM (Model-View-ViewModel)
87%
MVC (Model-View-Controller)
Which of the following methods violates data encapsulation?
Anonymous Quiz
26%
Using getters and setters
17%
Using private methods
56%
Directly accessing instance variables from external code
2%
Using protected methods
Which SOLID principle is violated if a class is responsible for both data processing logic and data persistence?
Anonymous Quiz
8%
Open/Closed Principle
8%
Interface Segregation Principle
3%
Dependency Inversion Principle
81%
Single Responsibility Principle (SRP)
Which Ruby library is most commonly used for dependency injection?
Anonymous Quiz
7%
Sidekiq
47%
Dry::Container
10%
Faraday
37%
ActiveRecord
🥴5💩3👍2👏1🤣1
Which of the following commands is used to create a new migration in Rails?
Anonymous Quiz
84%
rails generate migration
12%
rails db:migrate
4%
rails generate model
0%
rails db:rollback
How do you execute raw SQL queries in ActiveRecord?
Anonymous Quiz
69%
execute
9%
raw_query
19%
find_by_sql
3%
query
What does the DB.transaction block in the Sequel gem do?
Anonymous Quiz
4%
Automatically commits changes without rollback
1%
Filters records within a query
6%
Runs raw SQL queries
89%
Starts a database transaction and rolls back on failure
How do you rollback a migration in Rails?
Anonymous Quiz
2%
rails db:migrate:undo
1%
rails db:reverse
90%
rails db:rollback
6%
rails migrate:rollback
🔥4👎1
Which gem is commonly used in Ruby to manage PostgreSQL-specific features like JSONB and arrays?
Anonymous Quiz
18%
ActiveRecord
72%
Pg
7%
Sequel
2%
Redis
👍2
In a service-oriented architecture, how can you ensure loose coupling between services in Ruby?
Anonymous Quiz
62%
Use dependency injection to pass dependencies into services
5%
Use global variables to share data between services
15%
Use a Singleton to manage shared state
18%
Avoid using interfaces between services
🥱3👍1🤯1
What is the purpose of using the Repository pattern in a Ruby application?
Anonymous Quiz
20%
To store objects in memory for faster processing
8%
To manage database migrations in ActiveRecord
65%
To abstract data access logic from the business logic
7%
To define relationships between models
👍2
In a Ruby application using the Command pattern, what is the main advantage of encapsulating a request as an object?
Anonymous Quiz
8%
Making the application faster by executing commands directly
57%
Decoupling the sender from the receiver and making commands easier to queue or log
19%
Replacing service objects with simpler structures
16%
Avoiding the need for middleware
🥴7