+ 4
What is different between ......
Between Animal a = new Dog(); And Dog a = new Dog(); Animal is base class
3 Réponses
+ 4
Mohammad in the second case you have the access to the methods and variables of "Animal" class as well "Dog" class. Whereas, in the first case you only have access to the methods and variables of "Animal" class.
+ 2
I got it
Thanks
+ 1
1) You have an Animal type reference to point to a Dog type object. Only Animal class methods will be invoked if you use method overloading and only Dog class methods will be invoked if you use method overriding in your code.
2) You have a Dog type reference to point to a Dog type object. All the methods in the Dog class can be invoked through reference 'a'.