public interface interA
{
public int a = 5;
}
public interface interB
{
public int a = 10;
}
program 1
public class getInters implements interA, interB
{
public static void main (String args[])
{
}
}
//no error, the java support the way you see multiple interface..
program 2
public class getInters implements interA, interB
{
public static void main (String args[])
{
System.out.println ( interA.a );
System.out.println ( interB.a );
}
}
//no error,
/*
two interfaces can’t have methods and data members with the same signatures and names after all!
Answer for using Interface : Well technically they could provided you’re sure both interfaces will never be used on the same objects at the same time.
*/
No comments:
Post a Comment