'i faced problem in baseclass and derived class

I faced some problem in topic inheritence in this i make a Baseclass a "Animal" and its subClass "Dog" but after makin object of Dog i print no of legs ,eyes ,sound but after the code run there is written eyes=0;legs=0;& sound=null. Below is my code..

 class Animal{
    int legs;
    int eyes;
    public void setEyes(int i){
        i=eyes;
        return;
    }
    public int getEyes(){
       return eyes;
    }
    public void setLegs(int i){
        i=legs;
        return;
    }
    public int getLegs(){
       return legs;
    }
}
class Dog extends Animal{
    String sound;
    public void setSound(String i){
        i=sound;
        return;
    }
    public String getSound(){
       return sound;
    }

}
public class practice_oops{
    public static void main(String[] args) {
        Dog D=new Dog();
        D.setEyes(2);
        D.setLegs(4);
        D.setSound("bark");
        System.out.println(D.getEyes());
        System.out.println(D.getLegs());
        System.out.println(D.getSound());
    }
}


Solution 1:[1]

You should set eyes=i, legs=i, sound=i in the setEyes(), setLegs(), setSound() functions respectively.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney