Page 1 of 1

About Question enthuware.ocajp.i.v7.2.995 :

Posted: Fri Mar 22, 2013 12:37 am
by baptize
Hi there,
Explanation 4: Can you give me a sample code for an interface with a body?

Thanks.

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Fri Mar 22, 2013 6:45 am
by admin

Code: Select all

interface I1{

 int X = 10;
}

interface I2{
    int X = 20;
}

interface I extends I1, I2{
    int Y = X; //Error because of ambiguous reference to X
    int Z = I1.X; //Valid
}

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Sat Mar 23, 2013 11:02 am
by baptize
admin wrote:

Code: Select all

interface I1{

 int X = 10;
}

interface I2{
    int X = 20;
}

interface I extends I1, I2{
    int Y = X; //Error because of ambiguous reference to X
    int Z = I1.X; //Valid
}
Thank you ;)

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Tue Jun 03, 2014 4:38 am
by JakeVR
In Java 8 intarfaces may contain static methods and default methods. I thought that static methods were also available in earlier versions of Java

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Mon May 11, 2015 12:34 pm
by Vyacheslav
4. Fields of an interface may be declared as transient or volatile but not synchronized.
Is it possible, to specify the "volatile" for the public statics final variable?
What's the point? Flows would not be able to change the final variable.

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Mon May 11, 2015 7:58 pm
by admin
That's right. Volatile doesn't make sense for final variables because such variables do not change.

Re: About Question enthuware.ocajp.i.v7.2.995 :

Posted: Tue May 12, 2015 5:41 am
by Vyacheslav
Thanks for your reply.