Which of these is NOT valid Ruby syntax?
Anonymous Quiz
28%
x = ->(a, b) { a + b }
57%
y = { |x| x * 2 }
5%
z = Proc.new { |n| n ** 2 }
9%
a, b = [1, 2]
Which of these Ruby keywords is NOT related to exception handling?
Anonymous Quiz
3%
rescue
42%
catch
7%
raise
16%
ensure
32%
retry
What is the primary benefit of using Interactors (e.g., the Interactor gem) in a Ruby application?
Anonymous Quiz
10%
Replacing controllers with simpler classes
6%
Simplifying database queries
1%
Generating migration files dynamically
83%
Encapsulating a single use-case into a reusable and testable object
What does the pluck method do in ActiveRecord?
Anonymous Quiz
94%
Retrieves specific fields from the database as an array
2%
Deletes a record from the database
1%
Сreates an index for a field
3%
Joins multiple tables in a query.
How can you create a composite index in Rails?
Anonymous Quiz
4%
By creating separate indices for each column
75%
By specifying multiple columns in a single add_index call
11%
By adding the :composite option in the model
11%
Composite indices are not supported in Rails.
Forwarded from Ruby Interview | Ruby on Rails
What will this query return?
Anonymous Quiz
16%
This query will result in an error.
6%
Names and total order count for all records.
4%
Names with fewer than 5 orders.
74%
All names with more than 5 orders.
Forwarded from Ruby Interview | Ruby on Rails
What is the output of the following Ruby code?
Anonymous Quiz
41%
[2, 3, 4]
52%
[1, 2, 3]
6%
No output, error occurs
1%
[1, 2, 3, 4]
How do you create an empty hash in Ruby?
Anonymous Quiz
0%
empty_hash = ()
3%
empty_hash = []
80%
empty_hash = {}
17%
empty_hash = hash.new
Which of the following statements is true when using the UNION operator in SQL?
Anonymous Quiz
12%
It joins tables on a specific column
21%
It combines only those rows that appear in both queries.
38%
It combines two queries and includes duplicates.
30%
It combines two queries and removes duplicates.
What does the GROUP BY operator do in SQL?
Anonymous Quiz
3%
Removes duplicates from the result.
77%
Groups rows to apply aggregate functions (like COUNT, SUM, AVG) to each group.
4%
Combines all rows into one.
16%
Sorts data by a specified column.
Which SQL query selects unique values from a column?
Anonymous Quiz
0%
SELECT DIFFERENT column_name FROM table_name;
13%
SELECT UNIQUE column_name FROM table_name;
78%
SELECT DISTINCT column_name FROM table_name;
9%
SELECT DISTINCT * FROM table_name;
What SQL query retrieves the second-highest salary from the employees table?
Anonymous Quiz
2%
SELECT MAX(salary) FROM employees;
16%
SELECT salary FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
2%
SELECT salary FROM employees ORDER BY salary ASC LIMIT 1;
80%
SELECT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1;
Which of the following commands will delete a table permanently?
Anonymous Quiz
9%
DELETE TABLE table_name;
89%
DROP TABLE table_name;
2%
REMOVE TABLE table_name;
0%
CLEAR TABLE table_name;
How do you generate a new Rails model named Article?
Anonymous Quiz
3%
rails create model Article
4%
rails generate Article
91%
rails generate model Article
1%
rails new model Article