Introduction to Object-oriented programming

Introduction to Object-oriented programming

Posted in : Core Java Posted on : September 28, 2010 at 12:39 PM Comments : [ 0 ]

This section contains the detail decription of Object-oriented programming in Java.

Introduction to Object Oriented Programming

Object Oriented Programming(OOP) is the nucleus of Java. As it' name says this approach of programming is object oriented means object based. The object is a data structure who has attributes and methods.

Object is the instance of the class which have 'behavior' and 'states' or we can say 'properties' in other words. For example, lion has states like color, breed etc and also have behaviors like-growling, roaring etc.

If you look around, you will find many live example of objects like humans, bikes, cars, dogs etc.

Humans can have many states like name, complexion, nationality etc and the behaviors like talking, walking etc.

Java objects have very similar characteristics like real word objects having a state and behavior. A java object's behavior is shown via methods and it's state is stored in fields.

Object to object communication is done through methods and methods operates on object's internal state.

The Three OOP Principle

The following given mechanisms helps you to implement the object-oriented model :

Encapsulation :

Encapsulation is the mechanism that tie up code and data together and it also protect it from outside world. It acts like a protective wrapper that prevent code and data from random access by other code defined outside the wrapper.

In java the basis of encapsulation is the class. A class defines the structure and behavior(data and code) that will be shared by the object of the class. Each object contains  the structure and behavior of the class. That's why it is called instance of the class.

Inheritance :

In OOP, one object adopt the properties of another object through Inheritance. For example, a dog is a 'mammal' which is the subclass of 'animal' super class. The subclass has all the properties of super class. In Java, the subclass can acquire the properties of a super class by using 'extends' key word.

Polymorphism :

According to Greeks, the meaning of 'Polymorphism' is acquiring many forms. For example, the same function "add()" van be use to add two numbers and can also make to concatenate two strings. If same element can be use for multiple applications, it can be addess as 'Polymorphic'.

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics