Simple Implemention of Inheritance in java

Here we explain how to implement the Inheritance. For this we use one interface called SimpleInterface and two java calss one is SimpleInterfaceImp which implement the SimpleInterface and another is InterfaceTest.

Here we can see it one bye one:

SimpleInterface.java

interface SimpleInterface
{
    void fun( );
 }
 
SimpleInterfaceImp.java

class Test  implements SimpleInterfaceImp
{
  public  void fun( )
    {
         System.out.println("singh");
   }
 }

InterfaceTest.java

class InterfaceTest
 {
     public static void main(String args[])
     {
          Sample s=new Test();
          
            s.fun();
     }
 }

1 comment :

  1. I have to write a java program to manage apparel shop inventory by creating enum for various fields required to hold data for cloth.For example-Pattern enum can be created with following constants-(plain,stripes,cheks,linings);colour enum(red,green.blue,yellow),size enum(large,XL,XXL,medium,small),category enum(gents,ladies,kids),etc.Create a main method which facilitates entry of cloth in inventory as well as create a method to list all the available inventory.(Use linked list to add the items to the inventory)

    ReplyDelete