POLYMORPHISM
Polymophism
Polymophism concept එක සැකසෙන්නේ Overriding , Inheritance , Casting යන concept 3 එකතුවෙලා .
Super class එකක Method එකක් Sub class එකකදි Override කරාට පසු Casting කර Super class reference එක හරහා sub class method එකක් Run කරවීම Polymophism ලෙස හදුන්වයි (මෙහිදි සිදුවන්නේ Overriding ,Inheritance හා Casting යන concept 3 බවිතා කරලා "super class reference" එකක් use කරලා sub class method එකක් call කිරිමයි.)
Example:-
class Max{
void print(){
system.out.println("Max");
}
}
class Min extends Max {
void print(){
system.out.println("Min");
}
public static void main(String[] args){
Max ma = new Min();
ma.print();
}
}

Comments
Post a Comment