|
Object-Oriented ProgrammingJava is an object-oriented programming (OOP) that is based on how real world objects are made of many kinds of smaller objects. Object-oriented programming has several advantages. Some of these are making code easier to read and understand, the ability to reuse code and the reduction in development and maintenance costs. When writing programs in an object-oriented language you define classes of objects. Classes are templates that define the variables and the methods for multiple objects with common features. Objects are software bundles of data and related procedures and are often used to model objects you find in everyday life. Objects are the key concept to understanding object-oriented technology. Objects have state and behavior. An object maintains its state in variables and implements its behavior with methods. For example, a car object would have variables to indicate its state, eg moving at 50 km/hr and in 2nd gear. The car object would also have methods that allowed you to brake, accelerate and change gears. Anything that an object does not know or can not do is excluded from the object. Objects provide information hiding and modularity while classes provide the benefit of reusability. Car manufacturers reuse the same blueprint over and over again to build lots of bicycles. Software programmers use the same class over and over to again create many objects. | |||||||||||
|