midterm 2 theory review.txt

Card Set Information

midterm 2 theory review.txt
2015-04-10 12:40:06
diane cs140
diane cs140 midterm 2 theory review
Show Answers:

  1. Methods reside ____________ of your main method.
  2. In order to exedute the code in a method, you have to ___________________ the method by name and ___________________.
    call/invoke, pass it parameter(s)
  3. If the method _____________________, you can save it in a variable to use later, print it to the screen, or use it as a value in an expression.
    returns a value
  4. If the method doesn't return a value, then the return type of the method is ___________.
  5. Required parts of a method:_________________, __________________, _____________________, ______________________.
    return type, name, parentheses, body between {}
  6. Optional parts of a method: _____________, ______________________.
    modifiers, parameters between parentheses
  7. You can have two or more methods with the same name in a class (overloading), if the methods' input parameters differ by ________, _________, and/or _________.
    number, type, order
  8. You __________ overload based on return type.
  9. Parameter names and variables declared in the method are _____________ to the method.
  10. Primitive values passed to methods are pass-by-value --- i.e., the original value of the variable is ______________.
    not changed
  11. Arrays are a collection of variables of _______________ type(s).
    the same
  12. Arrays _________ contain class types.
  13. The size of an array is _____________ (the single instance variable of the array - length - is _____________).
    fixed, final
  14. You can access elements in an array using its __________________ and ______________.
    reference (name), an index
  15. The first index in an array is _________, while the last is the __________________________.
    0, length of the array - 1
  16. Arrays passed to methods are pass-by-sharing -- changes __________ be made to the array in the method.
  17. Arrays _______ be method parameters and be returned by methods.
  18. Arrays can be searched for a ___________________.
    specific element
  19. ___________________ search traverses the array in order and compares each element to what you are searching for.
  20. A search is more efficient if the array is _________________.
  21. A two-dimensional array created in the following way int a = new int[4][3] has ___ rows and ___ columns. In this declaration, a is a ________ dimensional array, a[2] is a ______ dimensional array, and a[2][0] is __________. The length of a is _______, while a[1].length = _______.
    4,3, 2, 1 , integer, 4,3
  22. Traversing a two-dimensional array is easily performed with _____________________.
    two nested loops.
  23. A ragged (jagged) array is an array with rows of different ________________.
  24. Multi-dimensional arrays ______ be method parameters and be returned by methods.
  25. Strings can be turned into a char[] with the help of the __________________ method.
  26. Strings mimic a character array and accessing a character at position i in a string happens with a call to the ____________ method.
  27. The ___________ method is used when you want to divide a delimited String into a String[].
  28. You can match a character, a sequence of characters of use __________________ to match any character in a selection of characters.
    square brackets, e.g. []
  29. Images can be read into a two-dimensional array with the help of the ________________________ class.
  30. In order to add an image into a JavaFX application window, you have to add the image to a __________, which is put into a __________, which resides in a ___________.
  31. Each _____________ should be in a .java file by itself.
  32. The name of the class is the name of the __________.
  33. A(n) __________ is a(n) ______________ of a class.
    object, instance
  34. A class defines the ___________ and behavior of objects.
  35. Objects of a class are variables of that ____________.
  36. Classes have ______________, they only specify the structure of objects of that type.
    no data
  37. The access modifier __________ means that the thus declared variable/object/method/class can be accessed by name directly from any other class.
  38. Instance variables should be ____________ to protect them from unauthorized or accidental changes.
  39. Getter and setter methods are ____________.
  40. Objects are created with __________.
  41. When objects are created, the ____________ of the class is called, which sets the values of the ______________________.
    constructor, instance variables
  42. Each object _______________ set of instance variables and methods as defined by the parent class.
    has its own
  43. Constructors ________________ a return type and a return statement.
    do not have
  44. Constructors have _____________ name ______________ the class.
    the same, as
  45. If you want to change the state of an object you ___________ call the constructor; you must call _______________.
    cannot, set methods
  46. You ____________ create your own constructors.
  47. Constructors ______________ call other constructors.
  48. The Java reserved word ____________ points to the object receiving the method call.
  49. The main method is ______________.
  50. ____________ variables and methods belong to the ____________ and there _________________ copy(s) of them.
    Static, class, is only one
  51. Static variables and methods are accessed with the ______________ name.
  52. A static method can access the instance variables of an object only if the object is _______________________________.
    passed to the method
  53. The state of an object passed to a method _____________ be changed, but the object __________________ be replaced with another object.
    can, cannot
  54. Wrapper classes are used to convert ______________ type values to "equivalent" _____________ type values.
    primitive, class