java objects, do I create an animal or a dog with animal speedy = new dog(); and why? -


i don't i'm creating actually... create object dog speedy = new dog(); call constructor dog() creates dog object , speedy name of reference it. if first dog named "animal" (dog extends animal) ?

your question isn't clear, if dog class extending animal, , want use dog methods/fields, need create new dog. create animal = new dog() still won't able access dog methods/fields (although shouldn't throw error)


Comments