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

Mind map

Objects & Classes

Marissa Farmer Computer Science English

Map content

Objects & Classes

  1. Objects/Instance (Car)

    • Attributes/Fields
      • Color, Number of Tires, Plate Number
    • Actions/Methods
      • Run, Brake
    • Constructing Object/Instantiating Class- use new!
      • assign created object to object/reference variable
        • Type/Constructor objectReference = new Constructor();
        • if the reference variable does not have a value, assign null
          • test if reference variable is null using == ex.  if (book==null) {      book=new Book(); } System.out.println(book.title);
      • call an object/field using .
        • objectReference.methodName objectReference.fieldName
  2. Classes are blueprints to create objects

  3. Classes

    • class className{      [class body] }
    • Class Name
      • Capitalize the initial of each word (Pascal), same as constructor name!
        • Saving file: ClassName.java
    • Fields (Variables)
      • Capitalize initial of each word except the first (Camel) (Same for Methods)
      • Primitive or references to objects (other classes)
    • Methods
      • Declaration/Signature
        • return value, method name, list of arguments
          • syntax: returnType methodName (listOfArguments)
          • return type can be primative, an object, or void (return nothing)
      • Body
        • code to perform action
      • Main- method providing entry point to application (how to invoke a specific class)
        • signature: public static void main(String[] args)
        • Passing Arguments
          • java className arg1 arg2 arg3
            • arguments must be strings
    • Constructors
      • constructorName(listOfArguments){      [constructor body] }
      • used to construct an object, sometimes called a constructor method, no return value
      • constructor arguments are used to initialize fields in the object

Information

Description
Computer Science Mind Map on Objects & Classes, created by Marissa Farmer on 20/05/2021.
Created by
Marissa Farmer
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?