Output of following Java Program?
(A) Derived::show() called
(B) Base::show() called
Explanation: In the above program, b is a reference of Base type and refers to an abject of Derived class.
In Java, functions are virtual by default. So the run time polymorphism happens and derived fun() is called.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.