How To Use Polymorphism in Java Programming Language
The Following script is the simplest way to declaring and using Polymorphism in Java programming language:
Class diagram:
Java program:
class Calculator{
int bagi(int x, int y){ // bagi = div
return x/y;
}
double bagi(double x, double y){ //bagi = div
return x/y;
}
}
class Polymorphism{
public static void main(String args[]){
Calculator Calc = new Calculator();
System.out.println("10/3 = "+ Calc.bagi(10,3));
System.out.println("10.0/3.0 = "+ Calc.bagi(10.0,3.0));
}
}
Output:
or you can see the simple video tutorial about plymorpshm in Java:
ShadowOfBdg© - All rights reserved.
No comments:
Post a Comment