Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 898 Bytes

OOP.md

File metadata and controls

20 lines (14 loc) · 898 Bytes

Java

It is a collection of objects that communicate via invoking each others methods

Object

objects have states and behaviours

Example: a dog has states - skin color, name, breed. It also has behaviours - tail wagging, sticking the tongue out, barking, eating

Class

A template/blueprint that defines the behaviours that the object of its type supports

Example: the class dog can have the state and the behaviours of the dog and can be used later to create the instance of the dog

Methods

This is basically a behaviour. A class can contain many methods, just like a dog can contain many behaviours. Logic is usually written here, like what to happen when the dog barks. Data is manipulated, and all actions are triggered

Instance variables

Each object has its own unique set of instance variables An objects state is created by the values assigned to these unique variables