Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Java Extending Interfaces

Like classes, interfaces can also be extended. This is done by the keyword extends as follows

Example
interface A extends B
{
	// Body of A
}
Example
interface SilanSoftware
{
	int x=10;
	string name="Mona";
}
interface SilanTechnology extends SilanSoftware
{
	void show( );
}
NOTE:
  • • Here the interface SilanTechnology will inherit both the constants x and name. It is pointed that the variable x and name are declared as simple variables. it is allowed because all the variables in an interface are treated as constants although the keyword final or static are not present.
  • • According to the concept of interface, it is possible to combine several interfaces together into a single interface. For example
Example:
interface A
{
    int x=10;
    string name="Mona";
}
interface B
{
	void show( );
}
interface Demo extends A,B
{
	- - - -
	- - - -
}

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext