Page 1 of 1

About Question enthuware.ocpjp.v8.2.1115 :

Posted: Sat Oct 01, 2016 5:09 am
by vlive07@gmail.com
Synchronised keyword can also assigned to static methods so incomplete facts!, and what about static methods inside interface?

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

Posted: Sat Oct 01, 2016 9:16 am
by admin
The explanation does provide complete facts. It clearly says, "The synchronized keyword can be applied only to non-abstract methods that are defined in a class or a block of code appearing in a method or static or instance initialization blocks. It cannot be applied to methods in an interface."

1. static methods of a class are indeed included in "Non-abstract methods of a class".
2. The statement, "It cannot be applied to methods in an interface", includes static or default methods.

HTH,
Paul.

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

Posted: Fri Dec 16, 2016 9:21 pm
by ibugaienko
Hi Paul,

Second option is ambiguous.
Any method of a [abstract, concrete] class. From the given wording it does not conclude that the class is abstract and if it is not - it could not have any abstract methods.

At the same time the correct answer appears to be missing information about static methods (granted static methods can not be abstract) by explicitly saying "instance".

Either the wording should be more accurate or I would not call this a "Very Easy" question.

BR!

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

Posted: Fri Dec 16, 2016 11:04 pm
by admin
The given wording does not conclude that the class is a concrete class either. It just says "class", which includes abstract class also. So you need to consider both the possibilities.
HTH,
Paul.

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

Posted: Sun Feb 05, 2023 3:59 pm
by robhun79
I agree with Ibugaeinko and maybe i am wrong but if the last option explicitly says "instance method", then i cant see how this could also mean static method. But maybe i am wrong.
"any non-abstract instance method of a class"

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

Posted: Sun Feb 05, 2023 4:55 pm
by admin
The option doesn't include static class.But the problem statement or the option do not claim to be exhaustive an list of things on which synchronized can be applied.

The option claims that synchronized can be applied to a non-abstract instance method, and this is true because it can indeed be applied to a non-abstract instance method. It doesn't say synchronized can be applied only to a non-abstract instance method.

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

Posted: Tue Feb 07, 2023 1:16 am
by robhun79
Yes, true, i understand, thank you.