Skip to main content

Posts

Showing posts with the label abstract method

Interface-1

Interface: -I nterface is a blue print just like a class. Interface is mainly used for achieving abstraction. Interface contains public static and final variables and public abstract methods. An interface can inherit by another interface. An interface can inherit more than one interface but a class cannot inherit interface, class can implements one or more than one interfaces. Instantiation of interface is not possible, we can create object of implemented class so interface reference can hold object of all implemented classes. All the variables of interface are by default public static and final, all the methods of interface are automatically public and abstract. Interface may be empty, called marker interface. interface A { } Interface can contains only variables. interface A { int a=100; int b=200; } Interface can contains only abstract methods. interface A { void disp(); void sum(); } Interface can contain variables and abstract m...