Anda di halaman 1dari 3


Object oriented programming (OOP) is a mindset which respects programming as a problemsolving dilemma on a grand scale which requires careful application of abstractions and subdividing problems into manageable pieces. The object oriented programming is a programming methodology using objects, that are data structures consisting of attributes (data members) and behaviour (member functions or methods) along with all their interactions to design applications and computer programs. The basic principal behind an oops language is to find out objects to manipulate and their relations with each other. Oops provides better flexibility and compatibility for developing large applications. There are some fundamentals in the oops concept that is used to develop java applications and programs: class and object. Class: A class is a description of an object. Object: An object is an instance of a class. The purpose of a class is to describe an object. An object is just what the word means in English: a thing, an item, a noun. For example, a car, a house, an employee of a company, a category of animals, An object consists of two major components: attributes and behaviours. The attributes or state or data members of an object are what the object consists of, and the behaviours or methods of the object are what the object does. When we write a program in oop, we get to describe what an object will look like by defining the attributes and behaviour of an object in a class. One of the analogies to explain classes and objects is to compare blueprints to a class. A blueprint of a house tells us what the house will look like when it is built, but it is clearly not a housejust a description of one. When a contractor follows the blueprints and actually builds an instance of a house, that house is an object. We can built as many houses as we want from a set of blue-prints, that is, we can have as many instances of a class (objects), as per requirement. Another example, we can consider is that of vehicles and cars. Here, vehicles is a category that defines cars, there can be many vehicles like a truck, a scooter, etc, but cars specifically define a particular instance of the class vehicles. So , here cars is a object of the class vehicles. Additionally, Encapsulation, Inheritance and Polymorphism are some significant concept in oops languages.

Encapsulation: Wrapping up of data and functions into a single unit is known as encapsulation. Encapsulation is the process of binding together the methods and data variables as a single entity. This keeps both the data and functionality code safe from the outside world. It hides the data within the class and makes it available only through the methods. Java provides different accessibility scopes (public, protected, private, default) to hide the data from outside. It is an important programming concept that assists in separating an object's state (attributes) from its behaviour. This helps in hiding an object's data describing its state from any further modification by external component. As we know an object can associated with data with predefined classes and in any application an object can know about the data it needs to know about. So any unnecessary data are not required by an object can be hidden by this process. It can also be termed as information hiding that prohibits outsiders in seeing the inside of an object in which abstraction is implemented. Along with this it also provides data abstraction, it is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface).

Inheritance: The phenomenon, by which an object is able to inherit characteristics from another object, is called inheritance, that is, an object is able to pass on its state and behaviours to its children. Inheritance allows a class (subclass) to acquire the properties and behaviour of another class (super class). In java, a class can inherit only one class (super class) at a time but a class can have any number of subclasses. It helps to reuse, customize and enhance the existing code. So it helps to write a code accurately and reduce the development time. Inheritance in OOP allows to define a general class and later to organize some other classes simply adding some details with the old class definition. This saves work as the special class inherits all the properties of the old general class and as a programmer we only require the new features. Polymorphism: The ability to take multiple forms. It is the ability to create a variable, a function or an object that has more than one form. Polymorphism is a generic term that means 'many shapes'. It describes the ability of the object in belonging to different types with specific behaviour of each type. So by using this, one object can be treated like another and in this way it can create and define multiple level of interface. Polymorphism allows one interface to be used for a set of actions, that is, one name may refer to different functionality. Polymorphism allows a object to accept different requests of a

client (it then properly interprets the request like choosing appropriate method) and responds according to the current state of the runtime system, all without bothering the user.