❮ Previous Next ❯

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( );
}
}

Output

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved