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( );
}
}
Output
Our Services:
Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects
SILAN Technology Call to: 9439202111 | 9658317757 | 0674-2361252