Java-Extend Interface

Extend Interface Interface is also extended by other Interface. One Interface can inherit another by use of the keyword extends. This is much like a way for inheriting class. When you inheriting two interfaces, you must provide implementations for all methods defined within the interface inheritance path. Program Program Source interface One { void methodOne(); … Read more…

Java-Nested Interfaces

Nested Interfaces An interface can be declared a member of a class or another interface. Such an interface is called a member interface or a nested interface. When a nested interface is used outside of its enclosing scope, it must be qualified by the name of the class or interface of which it is a … Read more…

Java-Accessing Implementations Through Interface References

Accessing Implementations Through Interface References You can declare variables as object references that use an interface rather than a class type. Any instance of any class that implements the declared interface can be referred to by such a variable. When you call a method through one of these references, the correct version will be called … Read more…

Java-Interface Variables must be Final

Interface Variables must be Final The members of an interface are always declared as final,¬†that the variable cannot be modified by the methods in the class. Program Program Source interface Data { int data1 = 50; int data2 = 100; } class Data1 implements Data { void getInterfaceValues() { System.out.println(“data1 = “+data1); System.out.println(“data2 = “+data2); … Read more…

Java-Interface

Interface An interface declares a set of methods and their signatures. The methods that are declared in an interface should not have implementation codes. A class that makes use of an interface should provide the codes for the methods declared in that interface. A class that implements an interface should provide the implementation codes for … Read more…