Day 14 - 28 August, 2024

Program 36 : WAP to understand concept of interface in java

interface MyInterface { void m1(); // public abstract void m1(); void m2(); // public abstract void m2(); } class TestInterface implements MyInterface { public void m1 () { System.out.println("This message from m1 method..."); } public void m2 () { System.out.println("This message from m2 method..."); } class P36 { public static void main(String[] args) { TestInterface ti = new TestInterface(); ti.m1(); ti.m2(); Copy Code
Expected Output: Scenario 1: Division by Zero
This message from m1 method...
This message from m2 method...