Q: giving value from one class to extended one Java I dont really know how to explain myself on this so ill just show you guys what im supposed to do and what i got.
My teacher told us to complete the rest of the code so that the main will work.
This is what was given to me:
public static void main(String args[]) 
{
dog buli=new dog();
cat felix=new cat(); 
cuckoo wallwatch=new cuckoo();
talks(buli);
talks(felix);
talks(wallwatch); }
}

the output should be:
guau 
miau
cucu
And what ive got(this class animals is where the main is too):
public abstract class Animals {
public String sound;
Animals (String sound){
    this.sonido = sound;
}
    public void talks(){
    System.out.println(sound);
}

And just the dog underclass(dog.java) since the three are the same:
public class dog extends Animals{

dog (String sound){
    sound = "guau";
}

}
To tell you the truth i have a lot of problems with java I've never had with other languages, 
i cant seem to understand anything related to classes or objects. :S
Thank you.

A: public abstract class Animals {
   private String sound;
   public Animal(String sound){
      this.sound = sound;
   }

  public void talks(){
     System.out.println(sound);
  }
}

public class Dog extends Animal {
   public Dog() {
      super("woof");
  }
}

public class Cat extends Animal {
   public Cat() {
      super("meow");
   }
}


public class Main {
     public static void talks(Animal animal) {
        animal.talk();
     }

    public static void main(String[] args) {
        Dog dog= new Dog();
        Cat cat = new Cat();
        talks(dog);
        talks(cat);
   }
} 


A: In the same class which contains main function, add the following function.
private static void talks(Animals animal) {
    animal.talk();
}

Then write following classes. (Note each class should be in a different file with name "class-name.java".... dog.java, Animals.java etc.)
Animals.java
public class Animals {
    public String sound;

    Animals(String sound) {
        this.sonido = sound;
    }

    public void talks() {
        System.out.println(sound);
    }
}

dog.java
public class dog extends Animals{

    dog (String sound){
        super(sound);
    }
}

Similarly the rest..
Good luck
