21. What does the respond_to_missing? method do in Ruby? A. Determines if an object has a certain method defined B. Overrides the default behavior of method_missing for a specific object C. Allows objects to handle method calls for undefined methods D. Raises an error if an object is called with a missing method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
22. What is a lambda in Ruby? A. A block of code that is executed within the context of a specific object B. An anonymous function that can be passed around like an object C. A closure that captures its surrounding scope and can be passed around like an object D. A block of code that is executed within the context of a specific object Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. What does the __FILE__ constant represent in Ruby? A. The name of the script being executed B. The name of the directory containing the current file C. The name of the current file being executed D. The current line number in the source file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
24. What is the purpose of using the method_missing method in Ruby? A. To override the default behavior of missing methods B. To define custom behavior for certain methods C. To prevent method calls on certain objects from raising errors D. To handle method calls for undefined methods dynamically Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
25. Which Ruby method is commonly used for converting a block to a Proc object? A. to_proc B. & C. proc D. lambda Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
26. What is the purpose of the trace_var method in Ruby? A. To create a new instance of a variable B. To track the usage of a specific variable throughout the execution of a program C. To print the current value of a variable to the console D. To set a callback that is triggered whenever a global variable is accessed or modified Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
27. What does the term "method chaining" refer to in Ruby? A. Passing multiple arguments to a single method call B. Calling the same method recursively C. Invoking multiple methods on the same object in a single line of code D. Passing the return value of one method as an argument to another method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
28. What is the purpose of the binding method in Ruby? A. To execute a block of code within the context of a specific object B. To capture the current execution context and create a binding object C. To generate a list of variables and their values within the current scope D. To execute a block of code within the context of a specific object Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
29. Which method is commonly used for dynamically defining attribute accessors in Ruby? A. instance_variable_get B. method_missing C. define_method D. attr_accessor Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
30. What is the purpose of the __dir__ method in Ruby? A. Returns the current directory path relative to the file being executed B. Returns the name of the currently executing file C. Returns the list of files in the current directory D. Returns the absolute path of the directory containing the currently executing file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board