A a = new A and B b = new B and a=b is that mean that's A a = new B ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

A a = new A and B b = new B and a=b is that mean that's A a = new B ???

10th Feb 2017, 4:55 PM
abderrahim bouali
abderrahim bouali - avatar
4 Answers
+ 1
Maybe, try it in the editor.
10th Feb 2017, 5:14 PM
Varun Moghe
Varun Moghe - avatar
+ 1
Works if B extends A.
10th Feb 2017, 5:17 PM
Tashi N
Tashi N - avatar
+ 1
Also works if both A and B are extended from the same parent or at least have a common ancestor. On some level it will work (but not necessarily the way you want it to) because all classes inherit from Object.
10th Feb 2017, 5:47 PM
ChaoticDawg
ChaoticDawg - avatar
0
yes is important to extends A thanks
10th Feb 2017, 5:21 PM
abderrahim bouali
abderrahim bouali - avatar