WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants
/*2. WAP a program that illustrates interface inheritance. Create two interface p1 and p2 . create Interface p which extends p1 and p2 and then create interface p12 which extends p12. Each interface declare one constants and one method. Create class Q which implements p12 and define all the methods of interface which displays value of constants*/
interface p1
{
int a=10;
void A();
}
interface p2
{
int b=12;
void B();
}
interface p12 extends p1,p2
{
int c=44;
void C();
}
class Q implements p12
{
public void A()
{ System.out.println("what is your number"+ a);}
public void B()
{ System.out.println("what is your number(b)"+ b);}
public void C()
{ System.out.println("what is your number(c)"+ c);}
}
class MK
{
public static void main(String []args)
{
Q q1=new Q();
q1.A();
q1.B();
q1.C();
}
}
interface p1
{
int a=10;
void A();
}
interface p2
{
int b=12;
void B();
}
interface p12 extends p1,p2
{
int c=44;
void C();
}
class Q implements p12
{
public void A()
{ System.out.println("what is your number"+ a);}
public void B()
{ System.out.println("what is your number(b)"+ b);}
public void C()
{ System.out.println("what is your number(c)"+ c);}
}
class MK
{
public static void main(String []args)
{
Q q1=new Q();
q1.A();
q1.B();
q1.C();
}
}
Comments
Post a Comment