class Animal{ void run() { } } class Dog extends Animal { void bark() { } } class Testing{ public static void main(String[] args) { Animal d
It's because you store your dog in the variable of type Animal which is only able to run(). There could be another animal Cat which isn't able to bark().
Animal
run()
Cat
bark()
If you want to let the dog bark() then you need to put in a Dog typed variable:
Dog
Dog rolf = new Dog(); rolf.bark();