Write a java program to demonstrate static keyword. The program consist three
method with parameters and also use the display method to show the output of
program.
public class StaticKeyword {
private static int first;
public static int add(int x, int y){
return x +y;
}
public static int sub(int x, int y){
return x - y;
}
public static int mul(int x, int y){
return x * y;
}
public void display(int x, int y){
System.out.printf("The addition of the two number is %d\nThe subtraction of the two number is"
+ " %d\n The multiplication of this two number is %d\n", add(x,y),sub(x,y), mul(x,y));
}
public static void main(String[] args) {
StaticKeyword key = new StaticKeyword();
key.display(20,5);
}
}
Comments
Leave a comment