Suppose I have a Triangle
class that extends a Shape
class. What is the difference between the following
Shape triangle = new Triangle ();
Triangle triangle = new Shape ();
Triangle triangle = new Triangle ();
?
Suppose I have a Triangle
class that extends a Shape
class. What is the difference between the following
Shape triangle = new Triangle ();
Triangle triangle = new Shape ();
Triangle triangle = new Triangle ();
?
I’m not sure the second one works.
I think you can do
Shape triangle = new Triangle();
if Triangle
extends Shape
but not the other way around.
I could be wrong about that.