Tuesday, 5 November 2013

Oops concepts in java


Java is a pure object oriented programming language. It is based on the concept of object. Java implements all the features of object oriented programming like

  1. Abstraction
  2. Encapsulation
  3. Polymorphism
  4. Inheritance
  5. Class
  6. Objects
  7. Methods

Object oriented programming provide a great flexibility, reusability, modularity and security to an application.

Data hiding is a very powerful feature. It provides security to various sensitive methods and variables.

Abstraction provides a way to hide the less essential properties so as to reduce complexity and increase efficiency.

Encapsulation is an information hiding and securing mechanism. It helps in restricting the access of data from the outside entities it means only the methods in a class can access its member variables. Encapsulation reduces the system complexity and increases robustness.

Polymorphism is a way to have more than one form of a method. In polymorphism, we use the method overloading and method overriding techniques.

Inheritance is used to reduce the code and reuse the already available code. Here we extend a base class to a derived class. The derived class then inherits the properties of its base class.

Class is a very essential entity in java. Every program in java has a class. Class is like a blueprint of an object. A class contains member variables and methods.

Object is soul of object oriented programming. An object is an instance of its class. Object is used to access the methods and variables in a class.

Methods are the operations that an object can perform. Methods define the behavior of an object.

All of the above object oriented programming concepts are widely used when we write java codes. OOPS concepts are one of the reason for the power and success of java programming language.

Features of java


Java is now one of the most popular programming language. Its success can be traced by its programming features and designs. The “write one run anywhere” is one of the most important feature.
Some of the features of java are as follows,

  1. Object Oriented
  2. Platform Independent
  3. Distributed
  4. Robust
  5. Secure
  6. Multithreaded
  7. High Performance

Object Oriented

Java is a purely object oriented language. Every variable, constant or function is a part of an object. An object or a class is always needed to access its member variables or member functions.

Platform Independent

It is one of the main feature of java. Java is platform independent at source code level i.e. at bytecode level. Java bytecode can be moved from one platform to another platform without any difficulty. Java is a strongly typed language, we have to declare type for every variable. The data types in java are consistent across all platforms. The java interpreter read the bytecode and converts it into the native language of the machine.

Distributed

Using java we can create applications than can run on different platform, GUI and operating system. Java is designed to make distributed computing easy and efficient. Java also provides various libraries for creating network based applications.

Robust

Java is a designed to create highly reliable and robust applications. It checks errors in code during compilation as well as at the time of interpretation. This eliminates various programming errors. Java does not have pointers and pointer arithmetic. In java programmer does not need to bother about memory deallocation as this task is done by garbage collection very effectively.

Secure

Java implements a good security mechanism to protect the system from viruses in code. It assumes that “no code is safe” for execution.

Multithreaded

Multithreading is now a very essential for software applications. Applications have to carry various tasks at a given time. Java provides a very easy mechanism to develop multithreaded applications that are capable to perform various tasks simultaneously.

High performance

Performance plays a very important role in software. It is always believed that execution of bytecode is not as fast as a complied language. But as the processors are advancing this become a myth. Java bytecode executes nearly as good as C or C++