Java-Method Overloading / Chapter - 6 / OOP's Concept

Method Overloading
Method Overloading:-


Two methods are said to be overloaded method if and only if, both methods having the same name but different arguments types.
In the old language like C method overloading concept is not available hence, we can't declare multiple methods with same name but different arguments types.
But in Java, we can declare multiple methods with same name but different arguments types.Such type of methods is called the overloaded method. This overloading feature of java reduces the complexity of programming.

Java- Overloading / Chapter - 6 / OOP's Concept

Overloading:-

  1. Two methods are said to be overloaded method if and only if ,both methods having same name but different arguments types.
  2. In old language like C method overloading concept is not available hence ,we can't declare multiple methods with same name but different arguments types.
  3. But in Java , we can declare multiple methods with same name but different arguments types.Such type of methods are called overloaded method. This overloading feature of java reduces the complexity of programming.                                                                                                                                        example:

    class Test
    {
             public void m1( )
             {
                 System.out.println( "no - arguments m1() method");
             }
               public void m1( int   x)
              {
                 System.out.println( "integer - arguments m1() method");
              }
              public void m1( double y)
              {
                 System.out.println( "double - arguments  m1() method");
               }
           public static void main( String [ ] args)
            {
                      Test    t   =   new    Test( );
                       t.m1( );
                       t.m1(20 );
                       t.m1(20.5);
              }
    }

    Output is:

Java- Method Signature / Chapter -5 / OOP's Concept



   Java- Method SignatureJava Method Signature



    1. In Java method signature consists of, methods names followed by arguments types.

Method Signature Syntax

     2. Return Type is not part of the method signature in java.
     3.The compiler will use method signature to resolve method calls.

example:-

Java- Method Signature / Chapter -5 / OOP's Concept

1. In Java method signature consists of, methods names followed by arguments types.


     2. Return Type is not part of method signature in java.
    3.Compiler will use method signature to resolve method calls.

example:-
class Test
{
        public void m1(int i)
       {
             System.out.println(int  type arguments");
         }   
        public void m1(String s)
       {
             System.out.println(String type  arguments");
         }   
        public static void main(String [ ] args )
        {
               Test   t    =new  Test( );
               t.m1(10);
               t.m1("javabychetan");
        }
}

Output

Java Inheritence / Chapter -4 / OOP's Concept


Java Inheritance

Inheritance



  1. It is also known as Is-A relationship.

  2. The main advantage of inheritance is code reuse-ability.

  3. By using extends keyword we can implement Is-A relationship.


example:-

class P

{

     public void m1()

    {

        System.out.println("Parent");

     }

}

class C extends P

{

   public void m2( )

   {

       System.out.println("Child");

    }

Class Test

{

     public static void main(String [ ] args)

    {

            C c =new C ( );

            c.m1( );

            c.m2( );

      }

}

 Output is:  


Java- Inheritence / Chapter -4 / OOP's Concept



Inheritance:-

  1. It is also known as Is-A relationship.
  2. The main advantage of inheritance is code reuse-ability.
  3. By using extends keyword we can implement Is-A relationship.
example:-
class P
{
     public void m1()
    {
        System.out.println("Parent");
     }
}
class C extends P
{
   public void m2( )
   {
       System.out.println("Child");
    }
Class Test
{
     public static void main(String [ ] args)
    {
            C c =new C ( );
            c.m1( );
            c.m2( );
      }
}
 Output is:  Parent
                   Child
            
Conclusion:-
  • Whatever method parent class has by default available to the child class and hence on the child reference we can call Both Parent & Child class methods.

Java- Encapsulation / Chapter -3 / OOP's Concept



Java Encapsulation

Java Encapsulation



  1. The process of binding the data and corresponding method into a single unit is nothing but "encapsulation".                  

  2. If any component follows data hiding and abstraction such type of component is said to be encapsulated component.


Java- Encapsulation Java- Encapsulation

The main advantage of encapsulation are:-



Java- Encapsulation / Chapter -3 / OOP's Concept

  1. The process of binding the data and corresponding method into a single unit is nothing but "encapsulation".                  
  2. If any component follows data hiding and abstraction such type of component is said to be encapsulated component.

Java- Abstraction / Chapter -2 / OOP's Concept



Abstraction

Abstraction:-


Hiding internal implementation and just highlighting the set of services what we are offering, is known as "Abstraction". 
example:-
Through Bank ATM GUI screen bank people are highlighting the set of services what they are offering without highlighting internal implementation.
Abstraction


The main advantage of Abstraction are:-




Java- Abstraction / Chapter -2 / OOP's Concept

Abstraction:-

Hiding internal implementation and just highlighting the set of services what we are offering , is known as "Abstraction".
example:-
Through Bank ATM GUI screen bank people are highlighting the set of services what they are offering without highlighting internal implementation.



The main advantage of  Abstraction are:-

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com