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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
baptize
Posts: 32
Joined: Wed Mar 14, 2012 5:45 pm
Contact:

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

Post by baptize »

Hi there,
Explanation 4: Can you give me a sample code for an interface with a body?

Thanks.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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
}

baptize
Posts: 32
Joined: Wed Mar 14, 2012 5:45 pm
Contact:

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

Post 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 ;)

JakeVR
Posts: 2
Joined: Thu Feb 28, 2013 2:02 am
Contact:

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

Post 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

Vyacheslav
Posts: 2
Joined: Tue Apr 28, 2015 5:39 am
Contact:

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

Post 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.

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

That's right. Volatile doesn't make sense for final variables because such variables do not change.

Vyacheslav
Posts: 2
Joined: Tue Apr 28, 2015 5:39 am
Contact:

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

Post by Vyacheslav »

Thanks for your reply.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 11 guests