This programming style makes me dizzy

What is the output of this Java program?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
import java.lang.*;
import java.io.*;


class Mammal{ 
    void eat(Mammal m){
        System.out.println("Mammal eats food");
        }
    } 
class Cattle extends Mammal{
    void eat(Cattle c){
        System.out.println("Cattle eats hay"); 
        } 
    }
class Horse extends Cattle{
    void eat(Horse h){
        System.out.println("Horse eats hay"); 
        } 
    } 

public class Main{
    public static void main(String[] args){ 
        Mammal h = new Horse();
        Cattle c = new Horse(); 
        c.eat(h); 
        }
    }


I am not a Java person myself. A friend sent me this. You could help him by adding a solution.

×

Problem Loading...

Note Loading...

Set Loading...