Really quick Java question.... about "super"

gopunk

Lifer
Jul 7, 2001
29,239
2
0
suppose i have a super class and a sub class, and they both have a function called "delete".

now suppose the delete method of the subclass calls super.delete so that it runs the delete method of the super class

if the superclass's delete function is recursive (it has a line that calls delete), will it call the delete of itself, or the delete of the subclass (this is what i'm hoping it does)?

thanks :)
 

Viperoni

Lifer
Jan 4, 2000
11,084
1
71
I woudl assume the super's delete method is called... not the subclass's, but don't quote me on that.
 

Stealth1024

Platinum Member
Aug 9, 2000
2,266
0
0
Well first of all I'm assuming this is not an abstract class which is being extended by the subclass (obviously if you have code in the superclass method this isn't the case, but just checking)

EDIT: Alright I have no clue...

You could always try it.
 

manly

Lifer
Jan 25, 2000
13,323
4,096
136
Remember Java method invocation is always virtual (unless a method is marked final, in which case overriding would not apply).

That should answer your question. :p
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
ok i just tested it, and indeed, it calls the subclasses one :)

i don't see why this is necessarily bad design...

anyways, thanks guys :)