Showing posts with label Inheritance. Show all posts
Showing posts with label Inheritance. Show all posts

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:  


Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com