What's the difference ? "I know the programme isn't right it's just an example " | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference ? "I know the programme isn't right it's just an example "

class fabric class dress extends fabric fabric silk = new dress() dress silk = new dress()

29th Mar 2018, 8:52 PM
Esraa A
Esraa A - avatar
4 Answers
+ 2
They're both referring to a dress object, but they're of different types: 1) Can only access members of fabric. It may be referencing a dress object, but silk is a variable of fabric type. If you cast silk to dress, you could access all its members. 2) This is a dress-type variable referring to a dress-type object, nothing unusual. Hope that makes sense.
30th Mar 2018, 10:15 PM
non
0
fabric doesn't have dress attributes. dress does have fabric attributes and its own. ^Simplified
29th Mar 2018, 10:25 PM
non
0
no what's the difference betwen the two silk
30th Mar 2018, 4:02 PM
Esraa A
Esraa A - avatar
0
thank's mate I appreciate it
2nd Apr 2018, 5:10 PM
Esraa A
Esraa A - avatar