Mind map
Ch. 4 Objects and Classes
Map content
Ch. 4 Objects and Classes
What is a Java Object?
- OOP can be used to show and solve real-life situations
- Java objects have attributes and actions called fields and method, respectively
- Fields and methods are optional
- Classes are used to create Java objects
Java Classes
- Class determines the object
- Consider 3 things when writing a class
- Class name
- The fields
- The methods
Fields
- variables that can reference to objects
- Follow camel naming convetion
- ie. maxAge
Methods
- define what objects can do
- Has declaration and body part
- Declaration part
- Return value
- can be a primitive (field)
- can be object
- can be void
- method name
- list of arguments
- Return value
- body part
- code that performs action
- Declaration part
Method "main"
- Provides entry to application
- allows class containing to be invoked
Constructors
- Every class needs at least 1 constructor
- compiler adds 1 if not specified
- no return value
- Every class needs at least 1 constructor
Creating Objects
- use "new"
- usually create reference variable
null Keyword
- no return value
- Test if reference variable is null with "==" operator
Information
- Description
- Mind Map on Ch. 4 Objects and Classes, created by Jose Hernandez on 18/05/2020.
- Created by
- Jose Hernandez
- Views
- 0
- Rating