Closed Li-Zizhen closed 5 months ago
I think because process()
in Foo
is not declared abstract, it is a concrete method. Because of this, since there is process()
in Bar
as well, it overrides the process()
method in Foo
, this is from inheritance. If it was meant to be the exact same method then there would be no process()
in Bar
.
(Correct me if I'm wrong)
@marclamp Thank for answering. But process()
in Bar will get exactly the same process()
in Foo by default. It should also show the process
even if it is exactly the same process
I think. Or do we not show the inherited method in subclass?
I was wondering about this as well.
Personally, I think if there is no overriding, then we do not need to write it out.
Below is the answer for practice part 2
From the answer we can see that, ProgressWatcher
does not have +update(int)
even it is implementing the Watcher
interface.
However, ProgressWatcher is an abstract class, so it might be different.
correct me if im wrong oo
Or do we not show the inherited method in subclass?
@Li-Zizhen Don't show unless it is overridden.
Thanks for responding.
In the class diagram below, how do we know whether the
process()
in Bar is exactly the same as the one in Foo (since theprocess
in Foo is not labeled as abstract) or it is Bar's overriddenprocess()
?Moreover, if the
process
in Foo is not labeled abstract, it must be a concrete method?