Basic Concepts

OBJECT ORIENTED PROGRAMMING CONCEPTS(OOP’S)

  • Class

          A Class is a way of binding the data and associated methods in a single          unit.Without a class there is no Java Program.

          Synatx for class:

          Class <Classname>{
           Variable declaration;
           Methods definitions;
            };

   Here, the class is a keyword which is used to create user defined                      datatypes.Class name is used to create objects.The class contains two parts      variable declaration and method declaration.Defining the class doesn’t create memory space for data members of the class.As soon as the object is created the  memory is assigned .

   Memory Space :

  • Memory Space for data members will be created on heap memory(Dynamic memory).
  • Memory space for  methods will be created on stack memory(when method called).
  • All constants are available in associative memory.
  • Class definition exists only one time but object can exists many number of times.

 

  • Object

    Blue  print of a class is known as an object.Instance of a class ,Logical runtime entity,Real world entity is also known as an object.To create object of a      class we must use opreator called new.This new opreator is know as dynamic memory allocation operator.

  Synatx for class:

          Class <Classname>{
           Variable declaration;
            Methods definitions;
      };

       <classname> objectname=new <classname ()>

   When the object is created we get the memory space for data members  of the class.

 

  •  Data Abstraction

     Data abstraction is a mechanism for retrieving the essential details without dealing with background details.Abstraction in java is         achieved by using interface and abstract class.

     What is Abstract class in Java?
     A class that is declared as abstract is known as abstract class.

    Syntax:
    abstract class <class-name>{}

   An abstract class is something which is incomplete and you cannot create instance of abstract class.
   If you want to use it you need to make it complete or concrete by extending it.

   What is Abstract method in Java?

   An abstract method in Java doesn’t have a body, it’s just a declaration. In order to use the abstract method, you need to override that method in        Subclass.

 

  • Data Encapsulation

     Data Encapsulation is the process of wrapping up on data and associated method in a single unit.

Data Encapsulation is bascially used for achieving data/information hidingi.e security.

 

  •     Inheritance

Inheritance is the process of taking the features from super class to sub class.

 Extends keyword is used to extend super class functionality to subclass.

   

       Types of Inheritances

 1.Single Inheritance:

    The single class is one in which there exists single base class and single derived class.

   2.Multi level Inheritance:

    Multi level Inheritance is one which there exists single base class,single derived class and n number of intermediate base class.

   3.Hierarchical  Inheritance:

     Hierarchical Inheritance is one in which there exists single base class and n number of derived classes.

   4.Hybrid Inheritance:

Hybrid Inheritance is a comnination of all Inheritances.It is not supported by java through the concept of classes but it is supported through 

    the concept of interfaces.  

  5.Multiple Inheritances.

   Multiple Inheritance is one in which there exists n number of base classes and single derived classes.It is not supported by java through the concept of classes      but it is supported through  the concept of interfaces.  

 

 

1+

3 comments on “Basic Concepts”

    • Shubhangi patil
    • 9th August 2017
    Reply

    Basic things is explained very clearly and this things is very helpful for new users.

    2+

    Users who have LIKED this comment:

    • avatar
      • Rohan lodhi
      • 9th August 2017
      Reply

      Thank you!!

      0

    • Pallavi
    • 9th August 2017
    Reply

    Very nice

    1+

    Users who have LIKED this comment:

    • avatar

Leave a Reply

Your email address will not be published. Required fields are marked *