1. Consider the following Interactive Ruby Shell console quotes. In one of the quotes, => is not the real irb result. Which of the following is that quote?
2. What is the output of the following code in Ruby? puts 'hello world'.sub(/[aeiou]/, '*')
3. Statement 1: When a Ruby program terminates, all running threads are killed, regardless of their states. Statement 2: You can wait for a particular thread to finish by calling that thread's Thread#wait method.
4. In the Ruby programming language, 'true' is a type of :
5. Statement 1: A thread shares all global, instance, and local variables that are in existence at the time the thread starts. Statement 2: Ruby threads are totally out-of-process, and are implemented outside the Ruby interpreter.
6. The package that contains information about an exception is an object of class exception or is one of class exception's children . Every exception returns information to understand the nature of the exception. Which of the following are provided by exceptions?
7. Which of the following are correct?
8. What is the output of the following code in Ruby? x= 'Ruby' + 'Strings' puts x y= 'Ruby' << 'Strings' puts y z = 'Ruby'.concat('Strings') puts z
9. In a Ruby installed environment, what happens when 'lrb' is typed in the command prompt?
10. output of the following Ruby code ? puts 'The product of 5,10,15 is #{5*10*15}';
11. Statement 1: When a Ruby program terminates, all running threads are killed. regardless of their states. Statement 2: You can wait for a particular thread to finish by calling that thread
12. What is output of this Ruby code? foo = 'testing' puts defined? foo puts defined? $_
13. Statement X: Method names should begin with an uppercase letter. Statement Y: Methods should be defined before calling them, otherwise Ruby will raise an exception for undefined method invoking.
14. Which of the following is used to cancel the method definition?
15. Assuming that f is an instance of the File class:
16. Command 1: $ ruby -c Command 2: $ ruby -C dir Which of the following statements regarding these two commands are correct?
17. colors= ['Red', 'Blue', 'Yellow', 'Green', 'Violet', 'Black'] Which of the given options will print the following output? Red Blue Yellow Green Violet Black
18. if there are two variables x and y, such that x=10 and y=5, then:
19. What is the difference between 'redo' and 'retry' statements in Ruby?
20. The following code snippet has two methods, namely 'method1' and 'method2'. def method1 x = 'This' y = 'is' z = 'test' end puts method1 def method2 x = 'This' y = 'is' z = 'test' return x, y, z end print method2
21. Which of the following statements regarding '.eql?’ and ’.equal?' are correct?
22. What is the output of the following code in Ruby? puts 'hello world'.sub(/[aeiou]/, '*')
23. puts 'Ruby String'.unpack('A6') What is the output of code in Ruby?
24. Given below is a Ruby code demonstrating Exception Handling with begin/end block, and rescue clauses. begin puts 'This is before the raise.' raise 'Raising an Error' puts 'This is after the raise.' rescue puts 'This is being rescued' end puts 'This is after the begin block.' What is the output the above code?
25. Which of the following statements regarding Ruby are correct?
26. Ruby makes it easy to write multi-threaded programs with the Thread class. Ruby threads are a lightweight and efficient way to achieve parallelism in the code. Which of the following calls have the same functionality as 'Threadnew‘?
27. In the following statement, what is contained in the argument 'caller'? raise InterfaceException, Keyboard failure, caller
28. Given below are two different cases of class definition, and object instantiation in Ruby. Case 1: ----------- class Demo end p = Demo.new Case 2: --------- class Demo2 def initialize(x,y) @x, @y = x, y end end p = Demo2.initialize(15,20) What happens when both these cases are executed separately?
29. output of code? $var = 1 print '1 -- Step 1\n' if $var print '2 -- Step 2\n' unless $var $var = false print '3 -- Step 3\n' unless $var
30. Which of the following statements regarding the Ruby programming language are correct?
31. What is the output of the following code? $debug=56 print Sample Text\n if $debug
32. Consider the following Interactive Ruby Shell console quotes. In one of the quotes. ==- Is not the real irb result. Which of the following is that quote?
33. Which of the following directives used with the method Time.strftime are correct?
34. In the Ruby programming language. 'true‘ is a type of:
35. Which of the following statements regarding catch and throw blocks are true?
36. What is the purpose of the following hash method in Ruby?
37. A file named 'test' is located at the location '/var/www/ruby/' 1. aFile = File.new('/var/www/ruby/test', 'r') 2. if aFile 3. aFile.syswrite('RUBY Testing') 4. print
38. Ruby code, a = hello world puts a.scan(/(..)(..)/)
39. Environment variables in Ruby: Statement 1: Environment variable RUBYLIB defines the search path for libraries. Statement 2: Environment variable RUBYLIB_PREFIX modifies the RUBYLIB search path by replacing the prefix of a particular library.
40. Which of the following statements regarding Ruby variables is incorrect?
41. DBD::Mysql implements some driver-specific functions to be used In Ruby. Given below is one such function: dbh.func(:insert_id) => Fixnum What is the purpose of this function?
42. Which of the following options represent correct Ruby syntax?
43. Output of Ruby code? print <
44. Output of Ruby code? puts 'escape the sentence using '\\' puts 'That\'s right, this is a test'
45. What is the output of the Ruby code (with line numbers) shown below? 1. (0...5).each do |i| 2. puts 'Value of local variable is #{i}' 3. end
46. What is the purpose of hash.rehash method in Ruby?
47. puts 'This is sentence 1.' BEGIN { puts 'This is sentence 2.' }
48. purpose of array.rassoc(key) array method in Ruby?
49. A thread shares all global. instance, and local variables that are in existence at the time the thread starts.
50. Assuming that d is an instance of Dir class:
51. Which of the following operators indicate continuation of a statement In Ruby?
52. range operators in Ruby: Statement X: The two.dot form. '..’. range operator creates a range from start point to end point inclusive. Statement Y: The three-dot form. '...', range operator creates a range from start point to end point exclusive.