Object oriented programming is the most preferred programming technique now a day only due to the flexibility of re usability. Re usability is actually an attribute that makes the object oriented programming more flexible and attractive.
As this programming is based on objects. Object is actually a collection of data and functions that are used to operate on that data. These objects are defined as independent entities because the data inside each object represents the attributes of object and functions are used to change these attributes as required by a program.
These objects act just like spare parts of any program. Thus, they are not limited to any specific program; rather they can be used in more than one application as required.
These objects are defined as an independent entity in a program, and afterward they can be used in any other program that needs the same functionality. This reuse of objects helps in reducing the development time of programs.
Example:
Inheritance in Java refers to the feature wherein the code/functionality of one class can be used in another class that extends this class. Example:
public class Animal {
...
..
}
public class Cow extends Animal {
...
..
.
}
Here the class Child extends the class Parent and hence the methods of Parent are available for Child to use. This way we are re-using the code in the parent class in the child class instead of re-writing the whole thing again.
As this programming is based on objects. Object is actually a collection of data and functions that are used to operate on that data. These objects are defined as independent entities because the data inside each object represents the attributes of object and functions are used to change these attributes as required by a program.
These objects act just like spare parts of any program. Thus, they are not limited to any specific program; rather they can be used in more than one application as required.
These objects are defined as an independent entity in a program, and afterward they can be used in any other program that needs the same functionality. This reuse of objects helps in reducing the development time of programs.
Example:
Inheritance in Java refers to the feature wherein the code/functionality of one class can be used in another class that extends this class. Example:
public class Animal {
...
..
}
public class Cow extends Animal {
...
..
.
}
Here the class Child extends the class Parent and hence the methods of Parent are available for Child to use. This way we are re-using the code in the parent class in the child class instead of re-writing the whole thing again.
Comments
Post a Comment
Please share your experience.....