Object Oriented Programming is a more efficient approach of programming, that focus on data rather than function.Object is quite similar to a real time entity that have some attributes and behavior, where Class is the blueprint of an object. we create object to work with everything. First we design a prototype of that object object with class.
The simplified syntax of code in Java is:
Quote:
class Rectangle{ //creating class
int length; //variable members (attribute)
int width;
void insert(int l,int w){ //member methods (behavior)
length=l;
width=w;
}
void calculateArea(){System.out.println(length*width);}
public static void main(String args[]){
Rectangle r1=new Rectangle(); //creating object
Rectangle r2=new Rectangle();
r1.insert(11,5);
r2.insert(3,15);
r1.calculateArea();
r2.calculateArea();
}
}
|