Inheritance, Generics and Instantiation

Carnelune Posted messages 5 Status Membre -  
Carnelune Posted messages 5 Status Membre -
Hello,

I am currently reviewing object inheritance, and I'm having trouble understanding all the relationships between concrete classes, abstract classes, and interfaces.
Here is an exercise with corrections that summarizes the different cases, but I can't seem to grasp everything.

http://img15.hostingpics.net/pics/260310jawa.jpg
_X: interfaces, $X: abstract classes.

Could someone explain the validation and invalidation of the propositions? I understand why there are double implementations, that abstract classes are non-instantiable, and that multiple inheritance is not allowed. But I'm still stuck...

Thanks in advance to those who will respond!

Configuration: Windows 7 / Firefox 23.0

1 réponse

KX Posted messages 19031 Status Modérateur 3 020
 
Already a very bad idea to use $ in class names!
For _ it's less serious but still to be avoided...

In any case, assignment is possible if the concrete type is a descendant of the declared type. For example, for the first two: E is a descendant of _N (via _A), but F is not. Trust does not exclude control.
1
Carnelune Posted messages 5 Status Membre
 
I think (I hope) that these are just conventions used here by the teacher to help us easily recognize classes and instances.

And for the third one, for example? Neither of the two descends from the other...

Thank you for your quick response!
0
KX Posted messages 19031 Status Modérateur 3 020
 
"I think (I hope) these are just conventions used here by the teacher to help us easily recognize classes and instances."
As long as you don't use them in practice...

"And what about the third one, for example? Neither of the two descends from the other..."
Of course it does, everything descends from _M so there’s no problem (H via $G, B, _Q)
0
Carnelune Posted messages 5 Status Membre
 
Thank you again, everything makes much more sense when explained simply like this!
0