GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Object-Oriented Programming Objects and Classes

Amanda Dischinger Englisch

Object-Oriented Programming Objects and Classes

Inhalt der Mindmap

Object-Oriented Programming Objects and Classes

  1. Object/Instance

    • Both fields and methods are optional for Java objects.
      • Attributes / Field (Java) car example
        • color
          • number of tires
            • plate number
              • number of values
      • Actions / Methods (Java) car example
        • run
          • brake
      • Most common way to create object is new keyword. new is followed by constructor of class
        • new Employee;
          • Want to assign object to an object variable to manipulate later
            • ObjectName Object reference = new Object()
              • Employee employee = new Employee()
                • can call its methods and fields but using a period (.)
                  • objectReference.methodName objectReference.fieldName
    • Classes
      • A class determines what object you get. It is a template used to create OBJECTS of identical type
        • All program elements in Java must reside in a class
          • Class Name
            • class file name must have a java extension
              • class className { [class body] }
                • class Employee { int age; double salary; }
            • Pascal naming convention used. where the initial of each word is capitalized
          • Fields
            • Camel naming convention used, where the initial of each word is capitalized except the first word
            • Can be primitive of references to objects. Can also refer to another object. (object can contain other objects)
              • Employees may have address field of type Address which is a class
                • Address address;
              • Null reference variable
                • A reference variable of an object that does not have a value
                  • if you declare a local reference within a method but assign it no object, need to assign null
                    • Book book = null;
          • Methods
            • Camel naming convention used, where the initial of each word is capitalized except the first word
            • Define actions that a class's objects can do
              • declaration / signature
                • consists of a return value, method name, and list of arguments
                  • return can be primitive, object, or void.
                    • void means method returns nothing
              • body
                • contains code to preform the action
              • returnType methodName (list of arguements)
                • if method take more than one argument: int add ( int a, int b)
            • The Method Main
              • provides entry point to an application that consists of multiple classes. only on class needs to have main method.
                • public static void main ( String [] args)
                  • can pass arguments to main to run a class
                    • java className arg1 arg2 arg 3 ...
      • Constructors
        • Every class must have at least one constructor. Looks like a method but does not have a return value.
          • Must have same name as the class
          • looking at the elements of a method, a constructor may have zero argument which is called nonarguement
          • constructorName (listOfArguments) { [constructor body] }
            • with second constrictor can pass values at same time to create object
              • new Employee (20, 90000.00)
      • UML Class diagram example with 5 fields and one method.
        • field and type separated by :
          • method's arguments in parentheses and return is written after :

Bilder und Dateien der Mindmap

  • Object-Oriented Programming Objects and Classes
  • Object-Oriented Programming Objects and Classes

Informationen

Beschreibung
Mindmap am Object-Oriented Programming Objects and Classes, erstellt von Amanda Dischinger am 25/05/2020.
Erstellt von
Amanda Dischinger
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck