Add ()
float X = Add(35.15, 10.10) ;
int Y = Add(12, 20) ;
int P = Add(10, 20, 30) ;
//Parent Class
class Stud{
public void Show() {
[Link](“Hi Students”) ;
}
//Overloaded method – Same name but different parameter
Public void Show(int S) {
[Link](“Hi Students of Semester “ + S) ;
}
}
//Child Class
class School extends Stud{
//Overrides Parent Class method (Runtime polymorphism)
public void Show(int C){
[Link](“Child Class Value: “ + C) ;
}
}
Public class Main{
Public static void main(String[] args){
Stud P = new Stud() ;
School M = new School() ;
//Polymorphic Object (Dynamic Dispatch)
Stud PMO = new School() ;
//Method overloading (Compile Time)
[Link]() ;
[Link](4) ;
//Method Overriding (Runtime)
[Link](20) ;
//Polymorphism action
[Link](30) ;
}
}
Output:
Hi Students
His Students of Semester 4
Child Class Value: 20
Child Class Value: 30