Custom Search

Thursday, February 28, 2013

OOPS CONCEPT IN JAVA


OOPS CONCEPT IN JAVA

OOPS

  1. OOP means Object Oriented Programming.
  2. It organizes a program around its data,i.e.,objects and a set of well defined interfaces to that data.
  3. An object-oriented program can be characterized as data controlling access to code.This is a technique used to create programs around the real world entities.
  4.  In OOPs programming model, programs are developed around objects and data rather than actions and logics.
  5.  In OOPs, every real life object has properties and behavior.
  6. This feature is achieved in java through the class and object creation. They contains properties (variables of some type) and behavior (methods).
  7. OOPs provides better flexibility and compatibility for developing large applications.
  8. OOPS concept includes 
  • class, 
  • method, 
  • inheritance, 
  • encapsulation, 
  • abstraction, 
  • polymorphism etc.
Object
  • Objects are key to understanding object-oriented technology.
  • Examples of real-world objects: your dog, your desk, your television set, your bicycle.
  • Real-world objects share two characteristics: They all have state and behavior. Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). 
  • Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming.

Class 
  • It is the central point of OOP and that contains data and codes with behavior.
  •  In Java everything happens within class and it describes a set of objects with common behavior. The class definition describes all the properties, behavior, and identity of objects present within that class.
  •  As far as types of classes are concerned, there are predefined classes in languages like C++ and Pascal. But in Java one can define his/her own types with data and code.  

Methods
  • Class can define both attributes and behaviors. 
  • Again attributes are defined by variables and behaviors are represented by methods. 
  • In other words, methods define the abilities of an object. 

Inheritance 
  1. This is the mechanism of organizing and structuring software program. 
  2. Though objects are distinguished from each other by some additional features but there are objects that share certain things common. 
  3. In object oriented programming classes can inherit some common behavior and state from others. 
  4. 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.
  5.  This saves work as the special class inherits all the properties of the old general class and as a programmer you only require the new features. 
  6. This helps in a better data analysis, accurate coding and reduces development time. 

Abstraction
  • The process of abstraction in Java 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). 

Encapsulation
  • This is an important programming concept that assists in separating an object's state from its behavior. 
  • This helps in hiding an object's data describing its state from any further modification by external component. 
  • In Java there are four different terms used for hiding data constructs and these are public, private, protected and package. 
  • 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.  

Polymorphism
  • It describes the ability of the object in belonging to different types with specific behavior 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. 
  • Here the programmers need not have to know the exact type of object in advance and this is being implemented at runtime.



No comments:

Post a Comment