Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
719 B
2
Indexable
Never
package com.company;

import java.util.*;


abstract class Animal {

    public int legs;
    public Animal(int legs){
        this.legs=legs;
    }
    public abstract void eat();
     void walk(int legs){
         if(legs>0)
             System.out.println("It can walk");
     }
}

class Fish extends Animal{

    @Override
    public void eat() {

    }

    @Override
    void walk(int legs) {
       if(legs<=0)
           System.out.println("can't walk");
    }
    Fish()
    {
        super(0);
        System.out.println("Don't Have legs");
    }

}

class Main {
    public static void main(String[] args) {
        Fish f = new Fish();
        f.walk(0);

    }
}