Mind map
Chapter 4: Objects and Classes
Map content
Chapter 4: Objects and Classes
Classes
- Objects/Instance
- Fields (Attributes)
- int age; double salary; string position
- references to objects
- maxAge, validAddress,age
- Methods (Actions or Functions)
- work (); receiveSalary ()
- define actions
- declaration/signature of the method
- consists of: return value, method name, and list of arguments
- returnType methodName (listofArguments)
- body
- contains code that perform the action
- return type: can be a primitive, an object, or void
- void: nothing
- accepts an argument:
- int negate (int number)
- does not accept arguments:
- double getSalary ()
- two or more arguments
- int add (int a, int b)
- main method
- public static void main (String [ ] args)
- java className arg1 arg2 arg3
- creating objects:
- new Employee () ;
- Reference Variable
- assign created object to a reference variable
- Employee employee = new Employee () ;
- employee is an object reference of type Employee
- Employee employee = new Employee () ;
- null keyword
- when a reference variable does not have a value
- Book book = null
- assign created object to a reference variable
- objectReference.methodName
- objectReference.fieldName
- Fields (Attributes)
- class Employee {
- constructor
- must have at least one
- same name as class
- no return value or void
- constructorName (listofArguments) { [constructor body] }
- Objects/Instance
Information
- Description
- Mind Map on Chapter 4: Objects and Classes, created by Jovain Sterling on 27/05/2021.
- Created by
- Jovain Sterling
- Views
- 0
- Rating