posted 19 years ago
lets say we have these classes.
class Tree {}
class Pine extends Tree{}
class test{
Tree tree = new Pine();
}
now, we all know that tree is now an instance of Pine and Tree but actually derives Pine. My question is Pine anyway extends Tree so an object of Pine also gets the characteristics of Tree. so, we can say
Pine tree = new Pine();
why is the necessity of the statement
Tree tree = new Pine();
In which scenario does this kind of object creation arise.