IT 114: Introduction to Java
Answers to Class 16 Ungraded Quiz

  1. Can objects hold more than 1 value?
    yes
  2. Do objects have names?
    no
  3. What do you call a method that does not work with the values inside an object?
    static methods
  4. What would you write if you wanted to get the length of the string str?
    str.length()
  5. What would you write if you wanted to get the first character of the string str?
    str.charAt(0)
  6. What would you write if you wanted to get the last character of the string str?
    str.charAt(str.length() - 1)
  7. What would you write if you wanted to know if the string str_1 was equal to str_2?
    str_1.equals(str_2)
  8. What would you write if you wanted a copy of the string str where all the letters were lowercase?
    str.toLowerCase()
  9. What would you write if you wanted to create an array of strings from the single string str where the delimiter was "-"?
    str.split("-")
  10. What would you write if you wanted to know whether the string str has the characters "hat" inside it?
    str.contains("hat")