Tutor HuntResources Java Resources

Java For Oops

How Java Handles OOPs concepts

Date : 05/07/2013

Author Information

Santhoshkumar

Uploaded by : Santhoshkumar
Uploaded on : 05/07/2013
Subject : Java

Object oriented programming is the evolution of modern enterprise programming and it is the back bone of recent technologies emergence. What is OOP? Approaching a problem in terms of real world objects is so called Object Oriented Programming Methodology.

Why OOPs? Since you are dealing with more real world objects it is very easy for the programmer to find out the dependencies, coding , testing if we approach OOP method to solve it.

What is Java? Java is an open source programming language which has inbuilt packages that supports OOP methodologies.

How does Java Supports OOP concepts and what are all those? Important OOP concepts are, 1.Object and Classes 2.Abstraction 3.Encapsulation 4.Inheritance 5.Plymorphism

1.Objects and Classes: Objects are entities that poses some behaviors. An object behavior can be identified based on its attributes and actions. Objects which have similar behavior is grouped as Classes. So the attributes and actions is termed as member variables and member functions of the class. All the java coding should be done in terms of classes objects only.

2. Abstraction Abstraction is simply hiding (unnecessary) details. It will be very difficult for a programmer to follow details which he never wants to know. Java allows us to create separate classes, so that the independent classes will be useful to support abstraction. For example: In a Bank Application, the customer class doesn`t need to know the details how the transaction class is implemented. Only the customer wants to know what are all the methods available for transactions. This simply hide the implementation details of those methods.

3.Encapsulation This is some what similar to abstraction, so I will provide a different note for this. Encapsulation simply means enabling capsulation. ie protecting the data from the outsider classes( that is how capsule protect its medicine from external environment ). In java encapsulation can be achieved by crating a class with private variables and public methods. So any class can access its methods but cant change the variable content.

4.Inheritance Inheritance is the process of one class acquiring the properties of another class. Inheritance is used to enhance code re-usability.

5. Polymorphism Poly means many morphism means forms. In real world a method can have more than one form. For example addition of two integers is different from addition of two floating point numbers. But both doing addition operation only. So it is irrelevant to name this methods with different names for example addInt() and addFloat(). This must be confusing for the programmer in long run. So Java allows to create more than one method or operator or constructor with same name. The java compiler will determine the respective method dynamically or statically.

This is how Java is providing functionalities or support to face OOPs methodologies.

Thanks for you reading. Explore Java without Fear.

This resource was uploaded by: Santhoshkumar