Java is an Object-Oriented Language. Java is associated with classes and objects, along with its attributes and methods.
A classes is collection of attributes and methods.
An object is an instance of a class.. A object is used to access property of class.
The keyword class is used to create a class.
Syntax to declare a class:
class <class_name>{
variable;
method;
}
We can create object using new keyword .
Syntax to create a object:
Class_name object_name = new constructor_name;
Example :
Fruit obj = new Fruit();
Comments