This isn't a test question but I know how fond people are of test questions so I'll phrase it as such:
This code outputs "Child Child" when run. I'd like it to output "Father Child". Look where it says "PROBLEM LINE". Basically, I have a child method calling a parent method. Within the parent it calls another parent method that is being overwritten by a child method. I'd like it to explicitly call the parent method and ignore the overwritten child. I tried replacing it with Father.this.identify() but no luck.
Catches: can't change access levels (has to all be public). [ August 06, 2007: Message edited by: Scott Selikoff ]
Replace the body of Father.identify() with a call to a new method Father._internalIdentify(), which contains the current body of Father.identify(). Have Father.save() call _internalIdentify() instead of identify().
I was hoping there was more of a java-y way to do it. Some access modifier or class tool like calling this/super.
Joined: Jan 30, 2000
You could also make identify() private (at least in Parent) or static. That would allow Child to declare its own identify() method without overriding the original , and give the desired output. If that doesn't work for you, there really isn't a simpler way than what EFH suggested.