inheritance in java codingsmania

Solutions on MaxInterview for inheritance in java codingsmania by the best coders in the world

showing results for - "inheritance in java codingsmania"
Alessio
09 Jan 2019
1class farmers
2{
3   String crops="Wheat";
4    void grows();
5    {
6       System.out.println(“Farmers grows Wheat”);
7    }
8}
9public class Animals extends farmers
10{
11    void eat();
12    {
13       System.out.println(“Animals eat Wheat”);
14    }
15
16public static void main (String args[])
17{
18    Animals obj=new Animals();
19    System.out.println(obj.crops);
20     obj.grows();
21     obj.eat();
22  }
23}
24
Matthias
05 Jan 2021
1Class farmers
2{
3   String crops="Wheat";
4    void grows();
5    {
6       System.out.println(“Farmers grows Wheat”);
7    }
8}
9Class Animals extends farmers
10{
11    void eat();
12    {
13       System.out.println(“Animals eat Wheat”);
14    }
15}
16Class Cat extends Animals
17{
18    void drink();
19    {
20        System.out.println(“Cat drinks milk”);
21    }    
22
23public static void main (String args[])
24   {
25       Animals obj=new Animals();
26       System.out.println(obj.crops);
27         obj.grows();
28         obj.eat();
29   }
30}
31