Java is an Object Oriented Language.It supports Object Oriented features like,
Objects in Java:
Object Oriented concepts are implemented to match the real life entities.Object can be a man,desk,car or anything which has a
Classes in Java:
A class is an collection of objects which holds the properties of the objects.Its is an blue print of the objects behaviour.
A clear definition of a class would be,consider a class as a car.
- Identity – A car has a color,number and unique body.
- Behaviour – A car can move,move backward etc.
- State – Car is idle,moving etc.
Creating a Class:
public Class Car
A Class can contain any number of variables,methods and objects.Here moving() and stop() are methods remaining things would fall as variables.There are types in variables we gonna have them later.
Creating an Object:
Object can hold values.It is used to match real time entities as i said earlier.Objects can be created using the ‘new’ keyword.Here the ‘new’ refers to a new memory allocation.
Object can be created in several ways.They are,
Syntax: ‘ClassName ObjectName;’
Syntax: ‘ClassName ObjectName = new ClassName();’
Syntax: ‘ClassName ObjectName = new ClassName(“Value”);’