What is the difference between child c= new parent() and parent c= new child() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between child c= new parent() and parent c= new child()

7th Aug 2019, 5:34 AM
Geek
Geek - avatar
2 Answers
+ 3
Supposing than child is a parent subclass, the difference is than child is implicitly safe to be "treated" like a parent but not the opposite.. This because child inherits all behaviours and data from parent while parent not
7th Aug 2019, 5:54 AM
KrOW
KrOW - avatar
+ 1
The child class generally contains more functionality and features than the parent class.
7th Aug 2019, 7:45 AM
Sonic
Sonic - avatar