Sunday 5 August 2012

JAVA for beginners. Starting JAVA. Object oriented programming concepts with examples.

If you want to learn JAVA, start from here. I am covering the very basic of JAVA in this post and this is also very important stuff for interviews.

JAVA is a programming language released by Sun Microsystems in 1995.

It is :

  • Simple
  • Object oriented (explained below)
  • Platform independent (write once run anywhere)
  • Dynamic

Now let me tell you why JAVA is Object oriented or what you mean by Object oriented programming.


Object Oriented Properties:


1. Abstraction:

Abstraction means hiding extra details and providing only the information that is necessary for the user.
For example. A person can ignore the details of how the engine, transmission and braking system work and is free to utilize the car as a whole.

Example in terms of java : If  we create a function "studentdetails" in class "student" which displays all the details of the student. Then when a user wants to use that function to display details of a student, he does not need to know what is in body of function or the definition of the function the only thing he need to know is the name of function to be called. Hence the complex details are hidden. This is known as abstraction.


2. Encapsulation:

The process of binding method and data together into a single unit called as class is known as encapsulation.
The data and code is bind to keep both safe from outside interference and misuse.
Encapsulation is like a protective wrapper that prevents the code and data from being arbitrarily accessed by other code defined outside the wrapper.
In Java the basis of encapsulation is class and in order to prevent data and code from outside interference each method or variable in java may be marked as public or private.
The public interface of class represents everything that external users of the class need to know or may know. The private methods and data can only be accessed by code that is member of the class.


3. Polymorphism:

One name having different forms is called polymorphism. The examples of polymorphism in java are function overloading(compile time polymorphism) and function overriding(run time polymorphism). (explained in next article)
A function having same name can have different definitions and different working, this is known as polymorphism.

To know more about polymorphism and overloading and overriding click here


4. Inheritance:

When a child class gets or inherits features or properties from its parent class then the parent class is called super class and child class is called sub class and this process is known as inheritance.


These features with proper coding will be explained in my other posts.


please give your suggestions.........








No comments:

Post a Comment