write a java program to implement the inheritance. code example
Example: 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();
}
}