Answers for "develop a java program in single inheritance"

0

inheritance in java codingsmania

Class farmers
{
   String crops="Wheat";
    void grows();
    {
       System.out.println(“Farmers grows Wheat”);
    }
}
Class Animals extends farmers
{
    void eat();
    {
       System.out.println(“Animals eat Wheat”);
    }
}
Class Cat extends Animals
{
    void drink();
    {
        System.out.println(“Cat drinks milk”);
    }    

public static void main (String args[])
   {
       Animals obj=new Animals();
       System.out.println(obj.crops);
         obj.grows();
         obj.eat();
   }
}
Posted by: Guest on January-21-2021
0

inheritance in java codingsmania

class farmers
{
   String crops="Wheat";
    void grows();
    {
       System.out.println(“Farmers grows Wheat”);
    }
}
public class Animals extends farmers
{
    void eat();
    {
       System.out.println(“Animals eat Wheat”);
    }

public static void main (String args[])
{
    Animals obj=new Animals();
    System.out.println(obj.crops);
     obj.grows();
     obj.eat();
  }
}
Posted by: Guest on January-21-2021

Code answers related to "develop a java program in single inheritance"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language