Hi today I got this question on my java exam regarding polymorphism.
Hamburger h = new Hamburger(); FastFood food1 = h; Food food2 = new Hamburger(); Item Item1 = food2;
"What would be the difference between using the object food2 and the object h? " - Write down all your assumptions.
I would start with the assumption that that Food is a superclass of Hamburger.
But then to the unanswered question. What would the difference between the object food2 and the object h?
As i understand polymorphism both objects still get the method defined in Hamburger. So what would be the difference?