Mind map
Object Oriented Programming: Java
Map content
Object Oriented Programming: Java
Class
- Fields
- Attributes/ variables within class
- camel naming: ex. 'firstLetters'
- Can be primitives or references to objects
- If variable is not referencing an object, the value 'null' must be assigned to avoid error
- '==' can be used to test if variable value is null
- If variable is not referencing an object, the value 'null' must be assigned to avoid error
- Can be primitives or references to objects
- camel naming: ex. 'firstLetters'
- Attributes/ variables within class
- Methods
- Define actions or functions
- To declare a method:
- returnType
- methodName
- (list of arguments)
- Can be blank, or have one or more (comma separated) arguments within parenthesis
- camel naming: 'firstLetter'
- (list of arguments)
- Either a primitive, object, or void
- methodName
- The method body is the code that performs the action
- returnType
- To declare a method:
- Main
- Entry point to application (allows class to be evoked)
- Only one class needs a main method per application
- 'java' keyword is used when running class to pass arguments to main
- Arguments (strings; space separated) are declared after className
- java className arg1 arg2 arg3 ...
- Arguments (strings; space separated) are declared after className
- 'java' keyword is used when running class to pass arguments to main
- To declare method main:
- public static void main (string[] args)
- Only one class needs a main method per application
- Entry point to application (allows class to be evoked)
- Define actions or functions
- Coded template to create objects
- 'class' keyword is used to declare a class
- The name of the class (Pascal naming: ex. 'FirstLetters')
- Braces flanking class body
- The name of the class (Pascal naming: ex. 'FirstLetters')
- class definition file must be saved by ClassName.java
- 'class' keyword is used to declare a class
- Constructor
- constructs an object
- Looks like method w/o return value
- Must have same name as the class
- Compiler adds a constructor to the class if there are none.
- Constructor arguments can be used to initialize the fields in the object
- Compiler adds a constructor to the class if there are none.
- Must have same name as the class
- Each class must have at least one constructor
- Constructor may have some, one, or no arguments
- 'new' keyword followed by the constructor of the class used to create object
- Created objects are often assigned to variables
- Looks like method w/o return value
- Object
- An objects methods and fields can be called by the reference variable and the method of field name connected with a period (.)
- objectReference.methodName
- An objects methods and fields can be called by the reference variable and the method of field name connected with a period (.)
- constructs an object
- Fields
Information
- Description
- Mind Map on Object Oriented Programming: Java, created by Ashley Kreynin on 17/06/2019.
- Created by
- Ashley Kreynin
- Views
- 0
- Rating