About Question enthuware.ocpjp.v7.2.1115 :

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

Moderator: admin

Post Reply
moormanm
Posts: 3
Joined: Tue Oct 01, 2013 12:08 pm
Contact:

About Question enthuware.ocpjp.v7.2.1115 :

Post by moormanm »

Do instance methods include static methods? The Synchronized keyword can refer to static methods as well as instance methods.

Q:
The synchronized keyword can be applied

A:
an instance method of a class

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

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by admin »

No, instance methods do not include static methods and vice versa. Both are different things.
synchronized keyword can be applied to instance as well as static methods.

A valid option does not have to cover all possibilities.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

moormanm
Posts: 3
Joined: Tue Oct 01, 2013 12:08 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by moormanm »

Thanks Paul!

winddd
Posts: 18
Joined: Wed Feb 11, 2015 10:48 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by winddd »

No, instance methods do not include static methods and vice versa. Both are different things.
synchronized keyword can be applied to instance as well as static methods.
In that case, there are no correct answers.

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

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by admin »

winddd wrote:
No, instance methods do not include static methods and vice versa. Both are different things.
synchronized keyword can be applied to instance as well as static methods.
In that case, there are no correct answers.
Why do you think so? Synchronized keyword can certainly be applied to an instance method of a class.

thank you,
Paul.
If you like our products and services, please help us by posting your review here.

winddd
Posts: 18
Joined: Wed Feb 11, 2015 10:48 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by winddd »

and static methods

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

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by admin »

It doesn't say that synchronized keyword can ONLY be applied to instance methods.
If you like our products and services, please help us by posting your review here.

gk_javauser
Posts: 9
Joined: Sun Jul 19, 2015 6:31 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by gk_javauser »

Hello,
I wanted to confirm something related to this answer choice's explanation:

a method in an interface
All methods in an interface are implicitly abstract.

Even though it is not stated here, all methods in an interface are implicitly public also right? Is there any time this is not the case?

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

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by admin »

Yes, all methods in an interface are always implicitly public as well.

Just FYI, in Java 8, interfaces may have non-abstract methods as well. These are called as "default" methods. Java 8 also allows static methods (which are also not abstract).
If you like our products and services, please help us by posting your review here.

gk_javauser
Posts: 9
Joined: Sun Jul 19, 2015 6:31 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1115 :

Post by gk_javauser »

admin wrote:Yes, all methods in an interface are always implicitly public as well.

Just FYI, in Java 8, interfaces may have non-abstract methods as well. These are called as "default" methods. Java 8 also allows static methods (which are also not abstract).
Thanks for the additional info and confirmation.

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests