#Inheritance

1 messages · Page 1 of 1 (latest)

normal sorrelBOT
#

<@&987246399047479336> please have a look, thanks.

quaint wharf
#

note we wont do your homework, you got any specific question about this in order to solve it yourself

#

lets start with the first:

m = t; // legal
#

what does this mean for class M and class T

fluid storm
#

M is Parentclass of T

quaint wharf
#

exactly

#

do that for the other ones

fluid storm
#

I do

#

But whats with the illegal ones?

quaint wharf
#

its useful for this for example:

m = t;
o = t;

means that T is a subclass of M and O, the question now is if M extends O or if O extends M
and therefore you use the illegal statement:

o = m; // illegal

which means that O extends M
so you get T -> O -> M

fluid storm
#

Ahhh thanks

#

Hm

quaint wharf
#

if you have a question about that just ask

fluid storm
quaint wharf
#

let me check real quick

#

yeah

#

you end up with this

fluid storm
#

Hm

#

I checked on Chatgpt and he says something other

quaint wharf
#

he wrong on that though

trail spruce
#

what did he say?

fluid storm
#

Chatgpt: "In summary, M could be a common superclass of T and X, while O is independent of the other classes or has a common superclass with T."

quaint wharf
#

did you specify its about java

fluid storm
#

Yes

quaint wharf
#

because some languages have multiple inheritance

fluid storm
#

I did

#

Can you maybe check the task again, to be sure, maybe we did a mistake

quaint wharf
#

but maybe wait for someone else to verify

fluid storm
#

Okay, thank you very much

trail spruce
# fluid storm Okay, thank you very much

if o had a common superclass with t, then o = t would be illegal, since t wouldnt derive from o (unless they're talking about the o -> t -> m relationship. o = t only works if t is a subtype of o

trail spruce
#

pretty sure squid is correct

fluid storm
#

Okay thank you

warped timber
#

it does not mean that O inherits from M

#

it doesn't imply it or anything, it just means that M doesn't inherit from O

#

i came up with this solution from another server he asked the question on
(solution deleted because i'm stupid as hell)

quaint wharf
warped timber
#

no

quaint wharf
#

check T

#

its both subclass of M and O

warped timber
#

yes

#

with interfaces, that works

#

but they cant be interfaces based on how they're created

#

smart

quaint wharf
#

yeah but all those are classes

warped timber
#

yeah so O has to extend M for that to work

#

since M cant extend O, that's given

#

yeah that makes more sense

quaint wharf
#

yeah peepo_heart

warped timber
#

god it is too late for me to be doing this shit

#

disregard fucking everything i said

quaint wharf
#

all good

warped timber
#

no its not all good, i am hired to be a java dev. i shouldnt have these issues

#

gdi

quaint wharf
trail spruce