Thursday, 3 December 2015

Java Object Oriented Programming concept

Java Tutorial
Java Object Oriented Programming concept:
If you are new to Object Oriented Programming then you need to learn few basic concepts before We starts. I will try to correlate these concepts with real world and simultaneously I will provide the java syntax for the same.   
First thing, We need to make up our mind that, here in java everything works with object. As java is a pure Object oriented programming language, we required at least a class and object to invoke the variables and methods of that class.
Before we starts with Java programming we need to understand the below basic concepts:


What is Class: A class is a Blueprint or instruction of how to provide a specific service.
Java Syntax:
class className{
------------------
}  
What is Object: Object is a thing that practically exists. For example every human, Trees, fruits, Animals are Object.
Java Syntax:
className objectName=new className();
Note that Class name and object name can be anything. Its upto you, what you want to give class name or object name.
What is Inheritance: Inheritance is a concept of inheriting (taking) the property of parent class.
Real life example is some people use to work with left hand as one of the parent is lefty. So that person has inherited the property from his parent.
Java Syntax:
class A{
-------------
}
class B extends A{
--------------
}

What is Polymorphism: when one task will be performed in different way, Its known as polymorphism.
Ex: method overloading and method overriding. We will discuss these topics later in detail.

What is Abstraction: Abstraction is a concept where internal details will be hidden to the outer world and only functionality will be exposed.
For ex: ATM machine, We use to withdraw cash from ATM machine in day to day life but we don’t know its internal details.
Java syntax: In java abstract keyword is used to make a class abstract.
What is Encapsulation: Encapsulation is a concept of binding or wrapping the data and code together.

Real life ex: capsule (a medicine), it is wrapped with different medicines. 

No comments:

Post a Comment