4.7 Week 7 - Java Object Terminology 3 - awt & swing 4 Operator Precedence and Associativity4.5 Week 5 - Threads 4.6 Week 6 - OOP -- Java Object Terminology

4.6 Week 6 - OOP -- Java Object Terminology

4.6.1 Reading and Web Sites

  1. re-reading van der Linden Chapter 2, The Story of O, Object Oriented Programming
  2. re-reading van der Linden Chapter 6, More OOP -- Extending Classes

4.6.2 Notes

  1. class
    1. Basic building block of a JavaTM program.
    2. Can contain methods.
    3. Can contain variables.
    4. Can contain constructors.
    5. Can contain initialization code that is run when the class is loaded.
    6. Is the blueprint for making class instances/objects.
    7. Can contain other classes.
    8. Should be reusable.
    9. Interface should be simple.
    10. Avoid public variables. Use set and get methods.
  2. objects
    1. I think of an object as:
      1. The public methods to manipulate the hidden data.
      2. static (one only data - in class, not object).
      3. non-static data, one set for each instance.
      4. An object or instance is created with new.
      5. Contains a "pointer" to its class and all of its methods.
    2. Sometimes called an instance.
  3. method signature
    The specific order and type of the calling arguments and implementation parameters of a method. Having multiple signatures is how a method is overloaded.
  4. method subsumption
    What happens when a type is "promoted" prior to the call to the method.
  5. field
    The name of data in an object. It is stored on the heap. The memory is allocated when the object is instaintiated with new.
  6. inheritance
    1. All classes but Object inherit from a superclass.
    2. inheritance includes all methods and variables, static and non-static.
    3. inheritance excludes all private members.
    4. method signatures and variable names can be overridden. Visibility is to the "innermost" class or block.
    5. All super constructors are called PRIOR to calling the subclass constructor.
    6. An overridden method or variable can be referenced using the keyword super.
    7. JavaTM allows only single inheritance. C++ uses multiple inheritance. The "same" result can be implemented in most cases using an interface.
  7. method
    1. I think of a JavaTM method as a C function.
    2. In JavaTM all methods of the same name MUST return the same type.
    3. A method signature is the specific type and order of calling arguments.
    4. Multiple method signatures is method overloading.
    5. JavaTM does NOT permit variable argument lists like C and C++.
    6. A method of one signature can call a method with a different signature in the same class.
  8. constructors
    1. Does NOT have a return type. It returns a reference to the newly created instance.
    2. Must have the same name as the class.
    3. Can be overloaded with multiple signatures.
    4. "Should" be placed at the top of the class.
  9. override
    If a subclass has a method with the same name and signature of a super class, the superclass method is being overridden.
  10. superclass
    The class that a subclass inherits from.
  11. interface / implements
    1. An interface describes a public set of methods that must exist in a class that implements the interface.
    2. A class that implements an interface must implement all of the variables and method signatures that are contained in an interface.
    3. Allows a class to implement/be a certain "type" of class without inheritance.
    4. A new class can only extend one class.
  12. overloading
    Having multiple signatures so that when a method is called with a specific set of argument types the compiler makes sure that the right method is called.
  13. static van der Lindenp55. (Version 4. p56)
    1. A static method does NOT take a reference
    2. static item occur only once.
    3. static public void main(String args[]) must be static.
  14. non-static
    1. A method that takes a reference. reference.method-name(argument-list)
    2. A variable that has been instantiated.
    3. Perhaps an "object" or an "instance".
  15. instantiate
    1. Using new to call a constructor.
  16. object destruction
    1. Think of it as an automatic call to free in C.
    2. Handled by the JavaTM garbage collector.
    3. Occurs when there are no outstanding references to an instance.
  17. reference
    1. What JavaTM returns from a constructor.
    2. Used with non-static object or instances
    3. Think of C pointers.
    4. Are dereferenced automatically. No * operator.
  18. dereference
    Happens in JavaTM automatically. This results in a LOT less segmentation violations or seg faults. <grin>.
  19. primitive types
    1. What the compiler / JVM really understands.
    Precision Primitive Type
    true/false boolean boolean
    8 bits signed integer byte
    16 bits unsigned integer char
    16 bits signed integer short
    32 bits signed integer int
    64 bits signed integer long
    32 bit floating point float
    64 bit floating point double
  20. wrapper types
    1. Creates a object for each of the primitive types.
    2. Has many "useful" methods associated with each one.
    Precision Primitive Type Wrapper Object
    true/false boolean boolean Boolean
    8 bits signed integer byte Byte
    16 bits unsigned integer char Character
    16 bits signed integer short Short
    32 bits signed integer int Integer
    64 bits signed integer long Long
    32 bit floating point float Float
    64 bit floating point double Double
  21. this reference
    Lets you reference a class variable instead of the method variable.
  22. super reference
    Lets you call a super method rather than the current class method.
  23. visibility
    If you use the same name, what variable or method is being referenced? The answer is the "closest" one (with the correct signature).
  24. package
    1. Organize a set of classes.
    2. Organized hierarchical manner.
    3. Can contain other packages
  25. public
    Can be referenced outside of the class.
  26. private
    Can only be referenced within the class.
  27. protected
    Members are accessible in package and in subclasses of the class.

4.6.3 Lab Assignment - None


Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site

4.7 Week 7 - Java Object Terminology 3 - awt & swing 4 Operator Precedence and Associativity4.5 Week 5 - Threads 4.6 Week 6 - OOP -- Java Object Terminology