I have two classes, a Parent, and a Child. Parent has two methods, one of which is overloaded by Child.
Okay, this is very simplified. Here's my question. If later in the code, Child.initializeGUI is called, will initializeGUI call the Parent getPanel method or the Child getPanel method? I think (and hope) it's the latter, but I wanted to verify. [ April 23, 2008: Message edited by: Jess Dancel ]
Why don't you just give it a try, maybe identifying which of the getPanel() methods the panel comes from, eg by setting it's color before returning it? This is the best way of learning how things work ...
Joined: Nov 07, 2007
That's a good idea, Guido. I'm currently knee-deep in the actual code that this version represents, but I'll try compiling a simple program when I get a chance.
I am, however, interested in the academic answer as well.
Joined: Dec 22, 2004
Academically, the getPanel() method of the Child class should be the one to be invoked. The only way of accessing Parent.getPanel() on a Child object is from within the Child object using super.getPanel().