GoConqr has a new look! Let us know what you think.

Mind map

Objects and Classes

Philip Mylet English

Map content

Objects and Classes

  1. Objects

    • attributes (fields)
      • quantitative and qualitative characteristics can refer to another object variables use camel naming convention
    • actions (methods)
      • actions define actions that a class's objects can do to declare a method use the following syntax:  returnType methodName (listOfArguments) use camel naming convention if a method takes more than one argument, two arguments are separated by a comma. 
      • declaration
        • part
          • retern value
          • method name
          • list of arguments
        • body
          • code that performs action
      • return type
        • the return type of a method can be a primitive, an object, or void. 
      • the Method main
        • provides the entry point to an application
          • an application normally has many classes and only one of the classes needs to have a main method
        • passing arguments to main when using java to run a class
          • to pass arguments, type them after the class name. two arguments are separated by a space all arguments must be passed as strings
    • creating an object
      • most of the time, you will want to assign the created object to an object cariable, so that you can manipulate the object later. to achieve this, you just need to declare an object reference with the same type as the object.  ex.  Employee employee = new Employee();  here, employee is an object reference of type Employee
      • new
        • always followed by the constructor of the class to be instantiated
    • once you have an object
      • you can call its methods and access its fields, by using the object reference that was assigned the object.  you use a period (.) to call a method or a field.  ex. objectReference.methodName objectReference.fieldName
      • reference variable
        • refers to an object. 
        • null value
  2. classes

    • a blueprint or template to create objects of identical type same number of objects as fields created capitalize the initial of each word (pascual naming convention determines the object a class definition must be saved in a file that has the same name as the class name. the file name must also have the java extension
    • consider three things
      • class name
      • fields
      • methods
    • class declaration
      • must use the keyword class, followed by a class name has a body within braces ex. class className { [class body] } 
    • UML diagram
      • rectangle with three parts
        • top most has the class name
        • middle part lists the fields
        • bottom part lists the methods
    • constructor
      • every class must have at least one constructor. otherwise, no objects could be created out of the class and the class would be useless.  must have the same name as the class ex. constructorName (listOfArguments) { [constructor body] } 
      • constructors typically look like a method
      • does not have a return value
      • arguments
        • may have a zero argument.  can be used to initialize the fields in the object

Information

Description
Mind Map on Objects and Classes, created by Philip Mylet on 27/05/2019.
Created by
Philip Mylet
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?