Java supports object oriented programming concept.
What is OOP ?
An oop contains a program around its data and a set of well defined functions to access the data.
Features of OOP:
1. Class: class is a user defined blueprint or prototype, from which objects are created. So, it represents the properties of an object.
2. Object: it is an instance of a class. We can create multiple objects of a class.
3. Abstraction: it is a process of hiding the certain details and showing only essential information to the user. There are two ways, by which we can archive abstraction in JAVA:
I. Abstract class
II. Interface
4. Inheritance: it is a process by which one object aquire properties of another object. It supports hierarchical classification.
5. Encapsulation- It is a mechanism that binds data and function, manipulate all that data and keeps both safe from outside interference and misuse.
6. Polymorphism-It means many form when we can perform an actions in different ways. We can write the same function name having different implementation
Creating a class:
class Demo
{
int a;
int b;
Demo
{
a=this.a;
b=this.b;
}
void method
{
int c = a+b;
System.out.println(c);
}
}
class Test
{
public static void main (string args[])
{
Demo obj = new Demo(2,3);
obj.method();
}
}