Write a Java program to demonstrate the use of static methods in interfaces
interface MathOperation { static int add(int a, int b) { return a + b; } static int subtract(int a, int b) { return a - b; } } public class Main { public static void main(String[] args) { int sum = MathOperation.add(4, 7); int sub = MathOperation.subtract(10, 3); System.out.println("Addition : " + sum); System.out.println("Subtraction : " + sub); } }
Addition : 11 Subtraction : 7
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions