Skip to content

Instantly share code, notes, and snippets.

@cheezedigital
Forked from jwoertink/ruby_quiz_1.md
Last active August 29, 2015 14:02
Show Gist options
  • Save cheezedigital/68b5a30dc0336a159462 to your computer and use it in GitHub Desktop.
Save cheezedigital/68b5a30dc0336a159462 to your computer and use it in GitHub Desktop.
  1. What is the difference between a local variable, and an instance variable? local to local, and instance to where ever
  2. What is the datatype of "DevPoint Labs"? string
  3. Assign the number 10 to the local variable n. N = 10
  4. Assign your name to the local variable name. name = "justin"
  5. What is an Array? a collection of data with a 0 based index
  6. Give an example of when you’d use an Array. when listing items
  7. What is a method? naming a set of instrucitons
  8. Name 3 iterator methods for an Array. each, sort, split
  9. Name 3 methods for a String. .chomp .reverse .upcase
  10. What datatype does 5 / 2 return? fixum
  11. What is a Hash? key based index using {}
  12. Give an example of when you’d use a Hash. like an array but more specific
  13. What is a class? classes are blueprints for how objects are created
  14. True or False; A class is a constant. true
  15. true and false are called what? boolean
  16. Write 4 conditional operators.
  • / + -
  1. Create a method called bucket that returns an empty array. def bucket e = [ ] end

  2. Name 6 ruby special keywords. (a keyword is a word that already has a special meaning) class, def, end, elsif, else, rescue

  3. How would you convert a number into a string? num.to_s

  4. How would you convert a string into a number? "4".to_i

  5. What is class inheritance? relation between two classes. Humans < Society

  6. What are modules used for? grouping together methods, classes and contants. googs

  7. What is a gem? code in a package shipped and ready to expedite some mutha fucking code

  8. Name 4 gems, and their purposes. sinarta - ruby in html - small apps rails - build fast apps quickly gosu - 2d and musical development. i wonder if we use clojure, and overtone with ruby pry - used for debugging. still need help with debugging

  9. What are comments used for in programming? sudo code, and remembering what was written

  10. In Ruby, only 2 things evaluate to false. What are they? false, 0

  11. Write 2 comparison operators. || && and these the same as conditonal as well?

  12. Write the code for “ if dave’s age is greater than or equal to 21” if daves_age >= 5 puts "drink more beer" end

  13. Instantiate a Car class. c = Car.new

  14. What is a method chain? adding two or more methods

  15. How would you capitalize and reverse a string then print it out to the console? "justin".capitalize.reverse

  16. What is a method to add an object to an array?

  17. How would you add an object to a hash?

  18. What are 2 valid datatypes of keys for a hash?

  19. What is a writer method? creating new file to write

  20. What is a reader method? reads only from the beginning of the file

  21. There are 4 types of variables. What are they? local, @instance, @@class, $global

  22. What does the question mark at the end of a method in ruby mean?

  23. What’s a common way to debug your code? using pry? honestly, I don't know.

  24. How would you return the string "two" from this array? arr = ["one", "two", "three"] arr[1]

  25. How would you return the string "DevPoint" from this hash? hsh = {:name => "DevPoint"}

  26. What is the datatype for :age? symbol

  27. What is the datatype for -36.98? float

  28. What is the datatype for [1, 2, 3]? array

  29. What is the datatype for "BOOM goes the dynamite"? string

  30. What is the datatype for 123412? fixum

  31. What is the datatype for {:food => "burger"}? sting interpolation

  32. What is the datatype for false? false

  33. What is the purpose of nil? 0 nothing.

  34. How would you print out the current date? Time.now

  35. How would you print out just the current year without using a Fixnum? time.year?

  36. What is String interpolation? allowing ruby code to appear within a string. #{1 + 2}

  37. What is String concatenation? with you take two or more strings and add them together

  38. What does OOP stand for? object oriented programming

  39. What does instantiation mean? creating objects of different types.

  40. What is the name of the method that is called every time an object is instantiated? in order to start using the object, it must first be initaizled, so instance variable

  41. What are arguments? passing ruby code in ()

  42. How do you pass an argument? with variables

  43. Write a method called eat that has an argument food with a default value of "cheese". request some help

  44. What is a loop? loops are used to execute the smae block of code for a specific number of times. googs

  45. How long has ruby been around? 19 years

  46. How are you doing on this quiz so far? mind spun

  47. Is anyone else hungry? actually, I am. I was, just at micky d's. college budget for a 34 year older, though I do feel like going out and grabbing a beer

  48. What are the pipe characters used for in a block? pass in a variable

  49. What is the difference between single quote strings and double quote strings? nothing

  50. Name some rules for naming a method? used to bunlde one or more repeatable statements. begin with lower case letters. should be defined before calling them. googs, just saying.

  51. How can you tell if a method is an instance or class method? class methods are methods that are called on a class and instance methods are methods called on an instance of a class. googs

  52. In an instance method, what is self? self is whatever the instance method is in

  53. How do you add a dependency to a file?

  54. I have a text file called names.txt. Each name is on it's own line. How would you print all the names in the file?

  55. When a method defines an argument that has a asterisk in front of a variable name, what is that asterisk referred to? e.g. def thing(*stuff)

  56. When a method defines an argument that has an ampersand in front of a variable name, what is that ampersand and variable name collectivly called? e.g. def thing(&stuff)

  57. What is it called when you see the do and end keywords together? block

  58. What does DRY stand for? dont repeat yourself

  59. What does DSL stand for? domain specfic language

  60. This question left blank intentionally. why?

  61. What does MRI stand for? matz's ruby interper

  62. What is the difference between JRuby and MRI? they seem comparabe, though one might be faster than the other.

  63. What would you use RubyMotion for? quickly lets one develop and test ios, and osx apps for iphone

  64. Does your head hurt? no, but my head is spinning.

@jwoertink
Copy link

3- You can't use a capital letter for a variable name.
8- split is not a method on array
16- those are math operators, not conditional operators
27- 0 returns true in ruby. false and nil are what return false
33- << or push or assigning a value to an index are 3 ways to do this
34- assign a value to the key like hash[:name] = "Jeremy"
35- string and symbols
36- a method to write a value to an attribute
37- a method to read a value from an attribute
39- this method will return a boolean
42- hsh[:name]
48- string interpolation isn't a datatype. The answer is hash
52- It would be Time.now.year
57- the name of the method is initialize
60- def eat(food="cheese"); end
66- there is a difference, look at string interpolation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment