« Back
interface Interface { // we can't declare variable we must initialize it int x; int x=10; // we can't provide method dfinition here void show(){ } void show(); void hi(); // we can have static method static void disp() { System.out.println("disp of interface"); } } // if we are implementing class we have to define all the method in class A other wise // make abstract class A implements Interface abstract class A implements Interface{} class B implements Interface { public void show() { System.out.println(" class B show"); } //if we are not defining method hi() also of Interface then we get compile time error //all method of interface defines wtih public access privilleage public void hi() { System.out.println(" class B hi"); } } class Test { public static void main(String args[]) { Interface i=new B(); i.show(); i.hi(); } }
×
Report a Problem:
Description:
Submit