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

Interfaces in package

It is possible to declare an interface in a package.
We know that an object cant created to the interface, so we have to implement the interface in a class then we can create object for implementation class.

Let us see a program to declare an interface in the package as follows

Example:
package  p;
public interface  A
{
	void display ( )     // public abstract
}
import p.A;
public class B implements A
{
	public void display ( )
	{
		system.out.println("duty is god");
	}
}
import p.B;
class test
{
	public static void main ( string args [ ])
	{
		B obj = new B( );
		obj.display( );
	}
}

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