Why doesn’t Java allow child object creation from parent constructor [closed]

In your case Boy IS-A Human, so you can create Human, with Boy’s constructor. But since (as per OOP) Human is not a Boy, thus you cannot create Boy’s instance calling the Human’s constructor.
So you cannot create a child instance directly using the super or parent constructor.
Boy boy = new Human(); NOT POSSIBLE
Human hm = new Boy(); POSSIBLE

Leave a Comment