Using interfaces in Java New problems

Suppose you have a displaceable interface and a class circle that implements displaceable Displaceable has a method called move (), which is implemented in circle, of course

What happens in the following scenarios?

Circle a =  new Circle(..);
Displaceable b = a;
b.move()

Does the object reference the circle's move method?

Solution

Yes, b.move () is the same as calling a.move () in the scene. This is polymorphism in action

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>