Object clone method & inheritance

W

Walter Mitty

Is there a way to specifically call the last defined clone() method?
As a java newbie the following excerpt from the JDK help confuses me a
little.

"By convention, the returned object should be obtained by calling
super.clone. If a class and all of its superclasses (except Object) obey
this convention, it will be the case that x.clone().getClass() ==
x.getClass()."

Surely if classA inherist from classB which (obviously inherits from
Object)and then

ref = new classB()

then

ref.clone()

calls classB.clone() implicitly?

Or does java call the base method and it's up to the implementor to
propagate the clone up through the hierarchy?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top