1 year ago

#348078

test-img

Yu Hu

creating a superclass object by using subclass' constructor

let's say we have a superclass Person and a subclass Child, I'm ok that Person a = new Child(); the statement works as Child is a subclass of Person, so it's permitted in java, but I can't stop thinking why and under what circumstances do we need to do this? thanks in advance for your help

subclass

superclass

0 Answers

Your Answer

Accepted video resources