Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a class that dynamically defines getter and setter methods for attributes based on an array of symbols.

Hard

Problem Statement

Create a class that dynamically defines getter and setter methods for attributes based on an array of symbols.

Sample Input

attrs = [:name, :age]
 obj = Dynamic.new

Sample Output

Ruby
30

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
class Dynamic def initialize # Your code here end end
Log in or sign up to run or submit your code.Log inSign up
Input
attrs = [:name, :age]
 obj = Dynamic.new
Expected Output
Ruby
30